declare an array of structures
-
How would I declare and array of structure so that it's visible in my class. This is in my declaration section Structure passenger Public passName As String Public passAdd As String Public passPhone As String Public SeatNum As String End Structure Public passengers(15) As passenger When I try to access passengers(0).passName in a sub, I get an error that says "Object reference not set to an instance of an object." So how do I declare it so that my whole class can see it? Thanks
Tom Wright tawright915@gmail.com
-
How would I declare and array of structure so that it's visible in my class. This is in my declaration section Structure passenger Public passName As String Public passAdd As String Public passPhone As String Public SeatNum As String End Structure Public passengers(15) As passenger When I try to access passengers(0).passName in a sub, I get an error that says "Object reference not set to an instance of an object." So how do I declare it so that my whole class can see it? Thanks
Tom Wright tawright915@gmail.com
When you create an array of structures, they are all initalized to zero. That means that all the string references in the structure are null (Nohting in VB). If you try to use a string that doesn't exist, you get that error message.
--- It's amazing to see how much work some people will go through just to avoid a little bit of work.
-
How would I declare and array of structure so that it's visible in my class. This is in my declaration section Structure passenger Public passName As String Public passAdd As String Public passPhone As String Public SeatNum As String End Structure Public passengers(15) As passenger When I try to access passengers(0).passName in a sub, I get an error that says "Object reference not set to an instance of an object." So how do I declare it so that my whole class can see it? Thanks
Tom Wright tawright915@gmail.com
-
Dave Kreskowiak wrote:
See this[^] thread for an explanation of what's going on.
I thought I saw the same kind of problem going on earlier :-O
If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa
-
When you create an array of structures, they are all initalized to zero. That means that all the string references in the structure are null (Nohting in VB). If you try to use a string that doesn't exist, you get that error message.
--- It's amazing to see how much work some people will go through just to avoid a little bit of work.
Okay, I think I was trying to do private mypassenger(15) as new passenger in my declaration section. However I get a compile error that says you cannot use te new operator on an array. BBBBUUUTTT now I see what I am doing wrong. I'll try it out and see what happens. Thanks Tom
Tom Wright tawright915@gmail.com