Forums
This topic is locked
First few words
Posted 15 Jan 2003 19:13:24
1
has voted
15 Jan 2003 19:13:24 Anonymous User posted:
I saw this on the DW app dev forum:<%=(left((TextValue),70))%>...
TextValue is the variable for the data you've retrieved from the database,
70 is the number of characters you want to have shown.
I'm looking for a way to do this with whole words. My idea was to set up a function that would count the number of spaces and then cutt off after that, but I don't know how to implement it.
What if you were to tell it to cut off after say the 15th "space" character? The reason I'm not sure how that would work is because I'm not sure how Access stores those characters. Would you happen to know some code that would count the number of spaces (instead of characters) as the data comes out of the database? This way it would stop at 15 words.
Better yet, you could set it to cut off after the first "chr(13)" so that you get exactly the first paragraph. That would be totally sweet... assuming it's possible.
Any ideas anyone?
Why be difficult when you can be impossible?
Replies
Replied 15 Jan 2003 19:33:01
15 Jan 2003 19:33:01 Owen Eastwick replied:
Try:
<%
varText = RecordsetName.Fields.Item("MemoField".Value
varPos = InStr(varText, VbCrLf)
varTruncated = Left(varText, varPos)
Respose.Write(varTruncated)
%>
Regards
Owen.
<hr></hr>
Used programming books and web development software for sale (UK only):
www.tdsf.co.uk/Shop.htm
Multiple Parameter UD4 / Access 2000 Search Tutorial:
www.tdsf.co.uk/tdsfdemo/
<%
varText = RecordsetName.Fields.Item("MemoField".Value
varPos = InStr(varText, VbCrLf)
varTruncated = Left(varText, varPos)
Respose.Write(varTruncated)
%>
Regards
Owen.
<hr></hr>
Used programming books and web development software for sale (UK only):
www.tdsf.co.uk/Shop.htm
Multiple Parameter UD4 / Access 2000 Search Tutorial:
www.tdsf.co.uk/tdsfdemo/
Replied 16 Jan 2003 20:30:59
16 Jan 2003 20:30:59 Anonymous User replied:
Thanks Owen. I tried it as you wrote it (replacing the appropriate recordset and field name), but I got this error:
Error Type:
Microsoft VBScript runtime (0x800A005E)
Invalid use of Null
/media/detail.asp, line 168
It occurred to me that maybe I needed to declare the variables and set their values, so I tried this:
<%
Dim varText
Dim varPos
Dim varTruncated
Set varText = ReleaseMasterDetail.Fields.Item("ReleaseBody".Value
Set varPos = InStr(varText, VbCrLf)
Set varTruncated = Left(varText, varPos)
%>
<%
Respose.Write(varTruncated)
%>
but that gave me this error:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[string: "WHAT: Several hundre"]'
/media/detail.asp, line 31
I know you laid this out for me, but I don't really get the syntax on this yet...
Why be difficult when you can be impossible?
Error Type:
Microsoft VBScript runtime (0x800A005E)
Invalid use of Null
/media/detail.asp, line 168
It occurred to me that maybe I needed to declare the variables and set their values, so I tried this:
<%
Dim varText
Dim varPos
Dim varTruncated
Set varText = ReleaseMasterDetail.Fields.Item("ReleaseBody".Value
Set varPos = InStr(varText, VbCrLf)
Set varTruncated = Left(varText, varPos)
%>
<%
Respose.Write(varTruncated)
%>
but that gave me this error:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[string: "WHAT: Several hundre"]'
/media/detail.asp, line 31
I know you laid this out for me, but I don't really get the syntax on this yet...
Why be difficult when you can be impossible?