Truncated string (still)
From: Serge Myrand (info_at_softdelirium.qc.ca)
Date: 08/18/04
- Next message: M-ar: "Re: ASP textfile edit problem"
- Previous message: Samuel Hon: "Re: Problem querying data from Access"
- Next in thread: Ray at <%=sLocation%> [MVP]: "Re: Truncated string (still)"
- Reply: Ray at <%=sLocation%> [MVP]: "Re: Truncated string (still)"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Aug 2004 09:39:00 -0300
Hi all,
On July the fifth I did ask about the same question on this forum. Ray
answer me with a with good examples but I miss something and I cannot
get the expected result. I will use the phrase Ray did use in his
response, which is: Joe's cat walked up to Mary O'Brien's dog and said,
"Meow!"
The phrase is stored in an Access 2000 table text field exactly as shown
above.
What I did is: I iterate the records gathering the information in a Tmp
variable in order to construct an HTML <TABLE> once at the EOF. Before
storing de F.Value in the Tmp variable, I format the text using
an UDF called FormatStr (see at the end of that text)
sValue = FormatStr(F.Value)
Response.Write sValue & "<BR>" '*** this output the
phrase as expected
Tmp = Tmp & "<TD BGCOLOR=" & sRowColor & "
valign='Top'>" & _
"<INPUT TYPE=Text NAME='Comment' SIZE=50 VALUE
=" & _
Server.HTMLEncode(sValue) & "></TD>"
this output only the first word which is Joe's (truncated at the first
space). Looking at the source in the browser, the phrase is as expected.
When using <INPUT TYPE=HIDDEN rather than INPUT TYPE=Text the phrase is
output as expected too! If I remove Server.HTMLEncode I get the same bad
output. The problem exist only in the "Text" control and the problem is
caused by the spaces between words. When I removed all spaces, the ' and
" are managed correctly and the whole phrase is output (whitout
spaces)..!
What to do?
function FormatStr(s)
dim i
dim NewStr
dim loFound
NewStr = ""
loFound = False
if s <> vbNullString then
if len(s) > 0 then
for i = 1 to Len(s)
if InStr(i,chr(34),s) = i then
loFound = True
NewStr = NewStr & chr(34) & mid(s,i,1)
else
NewStr = NewStr & mid(s,i,1)
end if
next
end if
end if
if (NewStr <> "") and (loFound) then
FormatStr = chr(34) & NewStr & chr(34)
'*** I tried to replace chr(34) with ' and with "&Quot;" with the
same result
else
FormatStr = NewStr
end if
Response.Write FormatStr & "<br>" '*** this output the phrase as
expected
' here is the formated phrase "Joe's cat walked up to Mary O'Brien's
dog and said, ""Meow!"""
end function
I hope my english is clear enough!
Help will be greatly appreciate
thank's in advance
serge
- Next message: M-ar: "Re: ASP textfile edit problem"
- Previous message: Samuel Hon: "Re: Problem querying data from Access"
- Next in thread: Ray at <%=sLocation%> [MVP]: "Re: Truncated string (still)"
- Reply: Ray at <%=sLocation%> [MVP]: "Re: Truncated string (still)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|