Make your own free website on Tripod.com
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 Integers (Continue)
Answer:

0
20
Blah
30

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

Dim Blah As Integer
A new Integer with the name Blah has been declared

Print Blah
Will print the Value that found in the Blah variable.
But there is nothing in the Blah variable!
The Blah variable has just been declared, and we
didn't put inside it any value yet.
The default value of any integer variable is 0.
When you write :
          Dim Blah As Integer
It's like you've written:
          Dim Blah As Integer
      Blah = 0

So it will print the value that found right now
in the Blah variable - 0

Blah = 10
Now the Blah variable holds the number 10

Blah = 20
Now the Blah variable holds the number 20
What's happened to the 10 that was inside it?
It has been deleted!
A variable can holds only one value, and when
you put in it a value, the old value is being immediately deleted.

So what is the differents between

      Blah = 20

       and

          Blah = 10
      Blah = 20


       ?

There is no differents!
In both cases the Blah variable will hold the number 20

Print Blah
Will print the value that found right now
in the Blah variable - 20


Blah = 30
Now the Blah variable holds the number 30


Print "Blah"
Will print the Text that found between the quotes - Blah


Print Blah
Will print the value that found right now
in the Blah variable - 30

Back  Forward