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!!!"
You can join two Strings together using the "+" operator.
Example:
Dim gogo As String
Dim popo As String
gogo = "Hello"
popo = "world"
gogo = gogo + " !!! " + popo
Print gogo
The code below will print Hello !!! world on the form.
The expression gogo + " !!! " + popo is equal to
Hello + " !!! " + world and that's equal to "Hello !!! world"
So eventually, the command that will be executed is gogo = "Hello !!! world"
Monday, 8 August 2011
Subscribe to:
Post Comments (Atom)
Subscribe to email feed



