The first is a Value Type these are mostly involve the type to do with numbers. (Double, Integer etc)
Dim x As Double
At this point the variable x has the value of 0 the default value for a double.
The second is a Reference Type these are mostly involve classes but it includes Strings.
Dim s As String
Dim c As someClass
At this point the variables s & c don't have a value, they are set to Nothing, think of them as a pigeon hole for the value.
And this is the reason why you get the
Quote
Object reference not set to an instance of an object.
For a reference types you have at some point give the declaration an instance of the type.
For example
Dim s As String=""
Dim c As someClass = New someClass
or
Dim c As someClass c = New someClass






MultiQuote



|