|
|
|
|
|
|
New to myExercises:
New to myNotes:
|
variable types Static variables Object variables Variables scope
Variables are temporary memory locations for data. Variable values can change during runtime. It can hold data that is not stored in a control on the user interface. It can hold data that is contained in a control's property; a computer can process data stored in a variable much faster than it can process data stored in the property of a control. Variables can only store one piece of data at a time. If you assign a new piece of data, the existing data in the variable will be replaced.
Using variables control the preciseness of data, since each variable is assigned a data type. The data type specifies what type of data a variable can hold, e.g. string, integer, etc.
If you don't assign a data type to a variable, it will be assigned the Object data type by default. The Object data type is the most flexible, as it caters for any kind of data, but it is less efficient. It uses more memory and your program will run slower because the computer has to work out what kind of data is stored in the variable.
Each data type is a class. A variable is instantiated (copied) from that class.
Variables are given a three character ID. This means of identification ensures that you know what data type each variable can hold when reading your code. It is an industry standard, and therefore a good habit.
When you thus declare a variable, attach the data type ID, e.g. strSurname or sngSales.
This list gives you the different data types and its three character ID
Rules for naming variables
To declare a variable means to say to Visual Basic: "hey look, I have created a new memory location". If you fail to delcare a variable, Visual Basic will not recognize it and therefore generate an error.
Syntax
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
All content on this site is free for private use only | Contributions are encouraged | Thank you to Netfirms for the free hosting | If copyright content is published here or links to certain content violates some right/law, contact the Webmaster to have it removed immediately.
Site launched: October 2005 | Updated: July 20, 2006 | Link exchange | Site map | Contact us |