Class: Unhandled Exception--Don't understand what's happening.

  • Thread starter Thread starter RDI
  • Start date Start date
R

RDI

Both of the fail messages are dialog boxes that say "An unhandeled exception of type 'System.NullReferenceException' occured in WindowsApplication5.exe

"Additional information: Object reference not set to an instance of an object."

Does anyone have any idea what could be going on now?

TIA

Public Class ExtensionList
Public Description As String
Public Extension As String
End Class

Public Sub ParseExt()
Dim Ext2 as ExtensionList
Dim Ext(0) as ExtensionList

Ext2.Description = "T" 'fails
Ext(0).Description = "T" 'fails

end sub
 
Correction: That SHOULD have read

Public Class ExtensionList
Public Description As String
Public Extension As String
End Class

Public Sub ParseExt()
Dim Ext2 as ExtensionList
Dim Ext(2) as ExtensionList

Ext2.Description = "T" 'fails
Ext(0).Description = "T" 'fails

--

RDI

(remove the exclamation from the email address)

Both of the fail messages are dialog boxes that say "An unhandeled exception of type 'System.NullReferenceException' occured in WindowsApplication5.exe

"Additional information: Object reference not set to an instance of an object."

Does anyone have any idea what could be going on now?

TIA

Public Class ExtensionList
Public Description As String
Public Extension As String
End Class

Public Sub ParseExt()
Dim Ext2 as ExtensionList
Dim Ext(0) as ExtensionList

Ext2.Description = "T" 'fails
Ext(0).Description = "T" 'fails

end sub
 
You didn't declare your variables with NEW.


Public Sub ParseExt()

'-- Declare using new
Dim Ext2 As New ExtensionList()
Dim Ext(2) As ExtensionList
Ext(0) = New ExtensionList()
Ext(1) = New ExtensionList()
Ext(2) = New ExtensionList()


Ext2.Description = "T" 'fails
Ext(0).Description = "T" 'fails

End Sub
 
Brian,

Thanks for the response. I just got back from my Thanksgiving vacation or I
would've replied sooner.

I could swear that I've declared similar arrays without using NEW. But I'll
look into it.

Thanks again.
 
Back
Top