Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to "VB"Encode a string

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I have a bunch of constants, and I Want the user to be able to preview their value, however, since the value retrived looks like this
[tt]
"bgcolor=" & chr(34) & "#000000" & chr(34)
[/tt]
I cannot sucessfully get it to work in
[tt]
Response.Write &quot;<TD &quot; & SplitThem(1) & &quot;>&nbsp;</TD>&quot; & vbcrlf
[/tt]
which in turn would make my HTML look like this.
[tt]
<TD &quot;bgcolor=&quot; & chr(34) & &quot;#ffffff&quot; & chr(34)>&nbsp;</TD>
[/tt]

is there any way to &quot;VB&quot;Encode the string, so that the text meant to be processed when normally used in a constant, gets encoded when I put it into a preview like above.
(HTMLEncode becomes useful when I Want show the value out to the screen before previewing)
[sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
hi Karl,

have you try the HTMLEncode method yet?
example: Response.Write Server.HTMLEncode(&quot;<HTML>&quot;)


Pepper
 
um, HTML Encodes &quot;HTML&quot; TAGS, I Want it to encode the VB Stuff. read my message again.

You'll notice Chr(34), &, etc Are NOT HTML tags [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
Currently to get the color preview to work I have to use alot of Replace, problem tho with this method, is that there can be an infinite number of VB constants, and symbols, and what not I would manually have to encode.

[tt]
if InStr(1, UCase(SplitThem(0)), &quot;COLOR&quot;) > 0 then
Response.Write &quot;<TD &quot; & Replace(Replace(Replace(SplitThem(1),Chr(34),&quot;&quot;),&quot;chr(34)&quot;, Chr(34)),&quot;&&quot;,&quot;&quot;) & &quot;> </TD>&quot; & vbcrlf
else
Response.Write &quot;<TD> </TD>&quot; & vbcrlf
end if
[/tt] [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
also if you are curious this is what it would look like if I had used HTMLEncode.

[tt]
<TD &quot;bgcolor=&quot; &amp; chr(34) &amp; &quot;#ddddff&quot; &amp; chr(34)>&nbsp;</TD>
[/tt] [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
I didnt put those there in the first place, they are part of the configuration file that comes with the web application, I must use it &quot;AS IS&quot;, also I noticed when using my replace method, it leave a gap of spaces between &quot; and # on the color, and I get the wrong color back (instead of a light pink, it shows back a light blue just cuz of the spaces).

Also I am not looking for an &quot;Easier&quot; way to continue using a bunch of Replace commands, I want to know if a function exist to do a &quot;VB&quot;Encode, because there are just simply too many possibilities, if the users plan on throwing in other VBscript constants, and etc for the constant's value. [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
here is a small Cut&Paste of the Constants.inc to show you what file I am working with, (my utility's main purpose is to allow the user to change the values of these constants, as well as being able to preview them prior to saving it back tot he file)

[tt]
<%' *************************************************
' Name: constants.inc
'
' copyright 1999, 2000 North Carolina ESC
'
' Changes:
' 02/07/00 SBH Add Geog Constants
' 02/04/00 SBH Add Index Constants
' 01/08/00 RMC Change HTML to code comments
' 01/07/00 WAS Change copyright notice
'****************************************************%>
<% ' Global Style Constants

'Index Page Footer
IndexFooter= &quot;<hr width=600><p align=center><font face=Arial size=1>North Carolina Employment Security Commission<br>Labor Market Information Division</font></p>&quot;

'Index Page Image Alt
IndexPageImageAlt= &quot;Welcome to WebSARAS - State and Area Research Analysis System&quot;

'Help Pages Footer
HelpFooter= &quot;<hr><center><font face = Arial size = 1><b>North Carolina Employment Security Commission<BR>Labor Market Information</b></font></center>&quot;

ProductName= &quot;WebSARAS&quot;
ShowWhatsNew= True
' background color defaults
gABgcolor= &quot;bgcolor=&quot; & chr(34) & &quot;#ffffff&quot; & chr(34)
gBBgcolor= &quot;bgcolor=&quot; & chr(34) & &quot;#f5fffa&quot; & chr(34)
gCBgcolor= &quot;bgcolor=&quot; & chr(34) & &quot;#c0c0c0&quot; & chr(34)
gDBgcolor= &quot;bgcolor=&quot; & chr(34) & &quot;#fffacd&quot; & chr(34)
gEBgcolor= &quot;bgcolor=&quot; & chr(34) & &quot;#c0c0c0&quot; & chr(34)
gFBgcolor= &quot;bgcolor=&quot; & chr(34) & &quot;#fff4f6&quot; & chr(34)
gGBgcolor= &quot;bgcolor=&quot; & chr(34) & &quot;#fffaf0&quot; & chr(34)
.... and so on
[/tt]

My ActiveX Dll, loads that file into a Collection, with rows marked as DataRows, and NonData Rows, the ASP only gets the Data rows, shows the user tha Variable, the Value, and allows them to change it and resave it back to the file, without affecting anything other than the value they changed.

and the ESC would not like it at all if I ended up telling them &quot;Um you guys are going to need to refrain from using Chr() and stuff like that, It's making my life a little harder to work with&quot; [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
also i fixed the color problem (having spaces after the &quot; and before the # of the bgcolor property) by replacing double spaces with nothing, lucky me that the result was exactly two spaces.

Response.Write &quot;<TD width=&quot;&quot;5%&quot;&quot; &quot; & Replace(Replace(Replace(Replace(SplitThem(1),Chr(34),&quot;&quot;),&quot;chr(34)&quot;, Chr(34)),&quot;&&quot;,&quot;&quot;),&quot; &quot;, &quot;&quot;) & &quot;>&nbsp;</TD>&quot; & vbcrlf

I still seek a way to automatically replace vb-like commands or process them, so thatI may be able to just throw it into the rest of the response.
[sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top