Truncated string (still)

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Serge Myrand (info_at_softdelirium.qc.ca)
Date: 08/18/04


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



Relevant Pages

  • Re: Search+Replace with Formats
    ... certain format - namely a different font (no different font-size, ... Dim oSl As Slide ... ' EDIT THIS TO REFLECT THE PHRASE YOU'RE LOOKING FOR ... Steve Rindsberg, PPT MVP ...
    (microsoft.public.powerpoint)
  • Re: Ray, please define "scientific evidence"
    ... No answer here, Ray? ... You haven't shown that hybrids are "rare exceptions". ... because of this alleged "special creation ex materia"? ... Google failed to come up with any other reference to this phrase, ...
    (talk.origins)
  • Who uses that catch phrase? Seriously, no, seriously.
    ... Ray Haddad despicably and cowardly ... "Who uses that catch phrase? ... all quotes above care of Cluestick-Haddad doing the CHIPCOG dance ...
    (misc.writing)
  • Re: Lloyd "Skip" Presss "Real" Face
    ... Bernie replied:- "Ah, so you were quite ignorant of the ... Ray then says:- "I already told you that there are many previous ... to the Bard, do explain. ... phrase* they have a specific meaning, ...
    (misc.writing)
  • Re: CEists are clowns doing the bidding of Atheists
    ... >> Ray Martinez wrote: ... > Verse 11 exists in the context of verse 1: ... Verse 11 presupposes that the phrase "Let the ...
    (talk.origins)