[.net] VB.NET Arraylist "Object reference not set to an instance of an object."

Started by
5 comments, last by Machaira 16 years, 3 months ago
    Dim temp As Entry
            temp = New Entry


            temp.Surname = TextBox_AddSurname.Text
            temp.Address1 = TextBox_AddAdd1.Text
            temp.Address2 = TextBox_AddAdd2.Text
            temp.PostCode = TextBox_AddPC.Text
            temp.PhoneNum = TextBox_AddPN.Text
            temp.InvoiceNum = TextBox_AddIN.Text
            temp.InstallNum = TextBox_AddIsN.Text
            temp.Windows = 1 
            temp.Doors = 1 

            
            DB.Entries.Add(temp)

Iv tried to add an object to my Arraylist, but it tells me the refernce isnt set to an object. The compiler tells me to use the New keyword, which Im doing. What am I doing wrong?
Advertisement
Perhaps either DB or its Entries property is not instantiated.
Quote:Original post by WanMaster
Perhaps either DB or its Entries property is not instantiated.


Yup it looks like maybe you have a problem with your Entry class?
[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
Cheers, that worked. I did

public DB as New Database

Do I have to instantiate all my vars in VB? Im familiar with c++ so does VB have constructors? I know i could Google but thats at least 4 clicks away
You have to instantiate any variable that's a reference type.

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

Quote:Original post by Machaira
You have to instantiate any variable that's a reference type.

Not if it's a shared(static in C#) class.
[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
Quote:Original post by daviangel
Quote:Original post by Machaira
You have to instantiate any variable that's a reference type.

Not if it's a shared(static in C#) class.

Then it's not technically a variable, is it? ;)

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

This topic is closed to new replies.

Advertisement