


The concept of a variable in VB.NET is to be used to store temporary information. A constant is an idea that a piece of information will be stored throughout the running of a certain application or method.
A primitive type of variable is a type that is stored in memory as a basic structure - that is that it does not contain any information other than the value it holds. They can also be seen as basic types which are the building blocks of any programming language.
There are several primitive types in VB.NET:
0D
which represents 0.
There are hundreds more types including the Bitmap and Graphics types which can be used to store and manipulate images. These types are however not considered primitive because they are a) not building block types and b) complex structures.
A variable stores information in memory (Random Access Memory or RAM) whilst the program runs. The length of it will vary in memory based on what it contains.
The following line shows how to define a variable in VB.NET:
accessModifier name [As Type]
Where Type
represents the type of the variable.
The [] refers to an optional parameter. This means that it is not entirely necessary to be included.
The following sample shows an example of a local variable being
declared using the Dim
(Declare In Memory)
access modifier:
Dim i As Integer
A constant is stored permanently in memory while a class or method is running. The reason for their use is because they use the exact amount of memory that is required to store their value.
Their use throughout programming can be described as broad. For instance, retaining the colour that is used for a dialog that is called through a class or retaining the maximum number of elements in a list.
Constants are defined in a similar fashion to variables. The following line depicts how to define a constant:
Const variableName As Type
Where Type
represents the type of variable and again,
the square brackets represents an optional parameter.
The following sample shows an example declaration of a constant in VB.NET:
'Define form dialog background colour Const backgroundColor As Color = Color.FromArgb(255, 93, 93, 44)
![]() | Happy New Year everyone! #2021NewYear 21 days ago |
![]() | Happy New Year everyone! All the best, Jamie Balfour. 21 days ago |
![]() | Retweet @PCMag: Adobe Flash support officially ends today. https://t.co/NNLcFK2yPx ![]() 21 days ago |