Memory and Data Type

A visual Basic variable declared with one of the numeric data types would take up one, two, or four bytes of memory, depending on whether it has the Byte, Integer, or Long data type, respectively. A long variable with a value of 1 takes up the exact same four bytes of memory that a Long variable with a value of 2,000,000 does. What’s difference is the range of numeric values that each of the numeric types can support. Because a Long variable takes up more memory than an Integer variable, larger (and smaller, in the case of negative numbers) can be stored in a Long. The Visual Basic String data type, on the other hand, takes up a different amount of memory depending on how much text is stored in it. A small amount of text (such as the word “Hello”) stored in a String variable would only take up a small amount of memory whereas the string variable with all of Shakespeare’s sonnets stored in it would take up considerably more memory.

First
Next