School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,118 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,989 people online right now. Registration is fast and FREE... Join Now!




Different Types of Variable.

 
Reply to this topicStart new topic

> Different Types of Variable., Why you get "Object reference not set to an instance of an object

AdamSpeight2008
Group Icon



post 14 Aug, 2009 - 10:30 AM
Post #1


In vb.net the are different type of datatypes.

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
CODE

Dim c As someClass
c = New someClass


Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

AdamSpeight2008
Group Icon



post 20 Oct, 2009 - 03:17 PM
Post #2
Note: If you pass a Reference Type to a function or subroutine via ByVal it is still a reference it is not a copy.
Go to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 11/21/09 01:34PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month