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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Ascii 1

Status
Not open for further replies.

TyGwyn

Programmer
Oct 5, 2005
31
GB
When I debug my program or send a string to a text box, I am not seeing Ascii characters such as chr(13) & chr(10), (vbCRLF)this appears to be PC biased, on different systems I get either | or a square which is usefull, why am I not seeing them on my laptop.
 
It depends on what is being used to display the string. The VB6 command window uses a variant of the textbox, and will interpret CRLF as a carriage-return line-feed combination, and move the caret to the next line.

If you need to see these values, convert the string to hexadecimal before displaying it.

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Ad$ = chr(10)&chr(13)
text1=ad$


if I run this same program on two of my PC's both with VB6 and SP6 one of them performs the CR and LF whilst the other displays ||, I do not understand why there is any difference, I can see that it is not the VB but must be some language setting on the PC's but as far as I can see they are identical, it is not only the text box if I set a break point on the text1 line and put my cursor on Ad$ I still get the same results as would be displayed in their text boxes, ie one of them shows me that the value for Ad$="||". but the other Ad$="".
 
A text box has a property called .MultiLine

Could it be that .MultiLine = True for one and False for the other?

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
No because when I look at the variable in debug mode I get the same results, and if I print to the immediate window, this again gives me the same results by performing the CrLf on one PC but displaying as characters on another.
 
What is the OS for the laptop? I know certain OS's (like Linux) interpret CR's differently than Microsoft OS's do.

Many Thanks!

AMACycle

American Motorcyclist Association
 
The OS is a good guess because the underlying textbox control must be behaving differently if the code is the same.
 
Lf then Cr is entirely different from Cr then Lf.

The VB6 instrinsic function MsgBox interprets Lf, Cr, CrLf, or LfCr all as "newline" symbols.

A multiline instrinsic Textbox control interprets CrLf as newline, but has no idea what you mean by LfCr and thus will display a pair of "default" symbols, which look something like "|" in many fonts. CrLf will give a similar pair of default symbols in a Textbox where Multiline = False.

In your second post here you use Chr(10) & Chr(13), which yields a variant string LfCr.

This serves once again to show why there is nothing 'leet about using the Chr/Chr$ functions where they aren't warranted and why the practice should be avoided.

When you want a newline in VB6 you should be using the intrinsic constant vbNewLine (which in Windows VB/VBA is equal to the constant vbCrLf). That's why it exists, to help programmers avoid such errors and to help others understand the original programmer's intent.

One is sometimes reminded of Obi Wan's advice to young Luke: "Dude, stop fighting it.
 
Sorry a slip up in the typing, It is the same piece of code on both pc's and it doesnt matter if I put vbCrLf or chr(10)& chr(13) the outcome is the same, all pc's are running XP pro with sp2 on.
 
It's also likely it's a font issue. Make sure that the same font (and version of the font) is loaded on both computers.

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top