Page 1 of 1

Data Types

Posted: Mon Oct 05, 2009 12:23 pm
by Cyclops
Data Types

As you may have noticed, VB supports several data types. These are what the main 'Types' that you can declare your variables as. For example:

Dim intCount As Integer

is an Integer. You always should tell Visual Basic what sort of data the variable will hold. This will make your code easier to use, and will also save memory. Different types of variables need different amounts of memory. You need to use the smallest amount of memory. For example, if you will need to store a number from 0 - 255 in a variable, you can save memory by declaring it as a Byte (1 byte) rather than as an Integer (2 bytes). This is not really very much memory, but if you are untidy with all your variables, your application will use much more memory than it has to.

The table below lists the various Data Types, what data they can store and how many bytes they use.
Data Types.jpg
Data Types.jpg (266 KiB) Viewed 3473 times