More about combining strings in Visual Basic


Suppose I have a string variable called str1 that contains the string "Bob".

To create a sentence from this string I could do the following:

outstring = "Hello, " + str1 + ", how are you?" + chr(13)

This creates a large string with the following sentence in it:

Hello, Bob, how are you? <Enter>

The chr(13) is the same as if you hit the <Enter> key at the end of the sentence.

To create the next line of the sentence, you would have to first add outstring to itself then add the new text to it. For example:

outstring = outstring + "I like the name " + str1 + "." + chr(13)

Now when I put outstring to a label as in:

label1.caption = outstring

The label will contain:

Hello, Bob, how are you?
I like the name Bob.

Go back to my main page

To e-mail me click here

Page created and maintained by Ron Patterson