Newbie: vb Character constants

  • Thread starter Thread starter Cindy M -WordMVP-
  • Start date Start date
C

Cindy M -WordMVP-

Hi all

I'm experimenting with the various VB vs NET string
manipulation functions.

If I have a text box in a Windows form, and I set the Text
property to

= szNote.Insert(i, DateString & vbCr)

vs.

= szNote.Concat(DateString, vbCr, szNote)

in the second instance I get black "block" characters
instead of a new line. There are other combinations of
vbCrLf and vbLF that exhibit a similar duality, depending
on whether I use the old Visual Basic Left and Mid
functions. I'm confused :-)

How does one know which character constant to use to get a
new line without the black blocks? Is it just trial and
error, or is there a logical set of rules?

-- Cindy
 
Hi Cindy,

This took my attention, because it has also to do with that question of
measuring the lines in a textbox.

Are you sure it are those commands MID or/and LEN,
I did try this,

Me.TextBox1.Text = "Hello" & vbLf & vbCrLf & _
"How are you?" & vbCrLf & vbLf & _
"I am fine" & vbCrLf & vbCr & _
"Do you know that the" & vbLf & vbCrLf & _
"The Packers are going to the Super Bowl."

For me it looks as it has to do with the text property from the textbox.

(I don't know about the "Packers" I copied it from a message in this
newsgroup)

Cor
 
* Cindy M -WordMVP- said:
I'm experimenting with the various VB vs NET string
manipulation functions.

If I have a text box in a Windows form, and I set the Text
property to

= szNote.Insert(i, DateString & vbCr)

vs.

= szNote.Concat(DateString, vbCr, szNote)

in the second instance I get black "block" characters
instead of a new line. There are other combinations of
vbCrLf and vbLF that exhibit a similar duality, depending
on whether I use the old Visual Basic Left and Mid
functions. I'm confused :-)

How does one know which character constant to use to get a
new line without the black blocks? Is it just trial and
error, or is there a logical set of rules?

'vbNewLine', 'Environment.NewLine', and my favourite
'ControlChars.NewLine'.
 
What object is szNote ?

Regards - OHM


Hi all

I'm experimenting with the various VB vs NET string
manipulation functions.

If I have a text box in a Windows form, and I set the Text
property to

= szNote.Insert(i, DateString & vbCr)

vs.

= szNote.Concat(DateString, vbCr, szNote)

in the second instance I get black "block" characters
instead of a new line. There are other combinations of
vbCrLf and vbLF that exhibit a similar duality, depending
on whether I use the old Visual Basic Left and Mid
functions. I'm confused :-)

How does one know which character constant to use to get a
new line without the black blocks? Is it just trial and
error, or is there a logical set of rules?

-- Cindy
 
The prefix should be

sName or strName

not sz. I think this is another convention/

Regards - OHM
 
* "One Handed Man said:
The prefix should be

sName or strName

not sz. I think this is another convention/

"should be"... It's simply an other convention...
 
If I remember correctly, it means zero indexed string, from the old C days
as opposed to some other langauges ( mention no names - where the index
started from 1 ).

:))

Regards - OHM
 
OHM,

Cindy has a Suisse email adres, naming in other languages is sometimes also
different.
(I do not know what she is using Suisse has 4 languages you know)

As I once wrote to Fergus also, very handy when you are using the English
language in your programs only for keywords (and everything as from the
framework of course) .

When you see code from non English persons you will see that (EricJ,
Herfried and Armin are doing that)

The benefit is that you never are mixed up with keywords.

Cor
 
OHM,
In VB6 I normally use sz to mean a string, as that is what I would use in
C++.

However in VB.NET luckily I have given up on attempting to prefix my
variables...

BTW: sz is short for null (zero) terminated string, which is the norm in
C++...

Just a thought
Jay
 
Yeah, your right I remember now, its a long time since I did any C/C++
stuff, I gave that up years ago.

Thanks for reminding me.

Regards - OHM

OHM,
In VB6 I normally use sz to mean a string, as that is what I would
use in C++.

However in VB.NET luckily I have given up on attempting to prefix my
variables...

BTW: sz is short for null (zero) terminated string, which is the norm
in C++...

Just a thought
Jay

One Handed Man said:
The prefix should be

sName or strName

not sz. I think this is another convention/

Regards - OHM

* "One Handed Man [ OHM# ]" <OneHandedMan{at}BTInternet{dot}com>
scripsit:
What object is szNote ?

A string.
 
* "One Handed Man said:
If I remember correctly, it means zero indexed string, from the old C days
as opposed to some other langauges ( mention no names - where the index
started from 1 ).

AFAIR it was the prefix for null-terminated ("z" stands for "zero")
strings (string ending with a 'ControlChars.NullChar'.
 
* "Cor said:
Cindy has a Suisse email adres, naming in other languages is sometimes also
different.

AFAIR she is English/German bi-lingual.

;-)
As I once wrote to Fergus also, very handy when you are using the English
language in your programs only for keywords (and everything as from the
framework of course) .

When you see code from non English persons you will see that (EricJ,
Herfried and Armin are doing that)

ACK. Names of variables, namespaces, classes, libraries are in English,
code comments are sometimes in German, sometimes in English, depending
on the "target group" who will read the code.
The benefit is that you never are mixed up with keywords.

Full ACK.
 
Hi Herfried,
'vbNewLine', 'Environment.NewLine', and my favourite
'ControlChars.NewLine'.
Merci :-) Finally found the information in the Help (the
Index wasn't too helpful), and I have a (silly) follow-up
question:

vbCrLf and vbNewLine are apparently the same
(Chr(13)&Chr(10))? Someone just decided "NewLine" is more
intuitive, so added it in?

-- Cindy
 
Hi OHM,
sName or strName

not sz. I think this is another convention/
Conventions :-) I used to use s, and some five years ago, a
(VB/A) developer I had to team up with told me "s" is used
to designate "Single", so to use sz to mean "String". I
never asked (nor worried) what the "z" was for, so I
learned something more in addition, today.

I'm flexible; I can adapt to just about any set of
arbitrary rules. The biggest problem is keeping track of
which to use with what set of people in order to keep thme
happy <g>

-- Cindy
 
Hi Cor,
For me it looks as it has to do with the text property from the textbox.
Most likely this is it, considering the controls are "pure NET" and the
codes are VB. When you're so deep into new stuff, juggling so many
different objects, you just grab the first thing that hits you :-)

<sigh>I wish books that purport to be about NET would consistently use NET
syntax. *Especially* where it makes a difference and should have been
obvious when testing the code that goes into the book (one by MS Press, no
less)!

-- Cindy
 
Back
Top