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
The process of creating variable called "Declaring"
To Declare (=create) Integer variable simply write:

Dim MyTest As Integer


What does the line above do?
It creates an Integer variable with the name MyTest.

Dim = Declare
MyTest = the name of the new variable
As Integer = The new variable type will be Integer.

Now you can put a number inside this variable.
You can do that by simple write:

MyTest = 10

The line above will insert the number 10 into the MyTest variable.
Now the MyTest variable stores the Number 10, but how
can you access this value from your program?
You can do that using the variable name. Example:

Print MyTest

The line above will write 10 on the form.
Pay attention to the differents between

Print MyTest

      and

Print "MyTest"

Where you putting a text inside quotes (Like in the bottom line),
Visual Basic treat it as a Text, and will print it As-Is.
The  Print "MyTest"   Line will print  MyTest  on the form.

Where you putting a text Without quotes (Like in the upper line),
Visual Basic treat it as a variable name, and will print the value that found
in the variable.
The  Print MyTest  Line will print the value that found in
the MyTest variable, therefore it will print 10 on the form.

Back  Forward