Write Your First Visual Basic Program

Lesson 2
Tutorials - Page 1 - Page 2 - Page 3 - Page 4 - Page 5 - Page 6 - Page 7 - Page 8 - Page 9 - Page 10 - Page 11 - Page 12 - Page 13

Working With Strings
String variables are meant to store Text.
When you assign a text to a String variable,
you must put the text inside quotes.

For example:

Dim Abc As String
Abc = "Good Morning"


Question: What will be printed on the
form after executing the following code?

Dim kuku As String
kuku = "Hello!!!"
Print "kuku"
Print kuku


Answer:

kuku
Hello!!!


Why is that? Lets pass over the code line after line:

Dim kuku As String
Will create a new String variable

kuku = "Hello!!!"
Now the kuku variable holds the text  Hello!!!

Print "kuku"
Everything that found inside quotes is being treated as text String,
So it will print   kuku    on the form.
The computer Is NOT associate the text "kuku" with
the variable kuku, because of the quotes.

Print kuku
Will replace the kuku with its value (Hello!!!),
and after the replacement will execute the new command Print "Hello!!!"

Back  Forward