Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

The old System.NullReferenceException still gives me headaches :)

 

here's my code

   Public Class Whatever

       Public Class Member
           Public name As String
           Public age As Integer
       End Class


       Dim membri(0) As Member

       Public Sub A_Sub()
           membri(0).name = "Test"
       End Sub

   End Class

 

Whenever I call the A_Sub method, I get a system.nullreferenceexception reffering to that line membri(0).name = "Text" . What should I do

Development & Research Department @ Elven Soft
  • Administrators
Posted

You need to instantiate the object at position 0 in the array.

   Public Class Whatever

       Public Class Member
           Public name As String
           Public age As Integer
       End Class


       Dim membri(0) As Member

       Public Sub A_Sub()
           membri(0) = new Member()
           membri(0).name = "Test"
       End Sub

   End Class

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
Does the array .answers contain anything at all?

 

Oh , Thanks, I deleted my message while u were replying, because I figure it out by myself ... thanks a lot, again

Development & Research Department @ Elven Soft

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...