G
GrandpaB
When I attempt to run the following code I get the
following error:
An unhandled exception of
type 'System.NullReferenceException' occurred in Art.exe
Additional information: Object reference not set to an
instance of an object.
Being new to VB.Net I'm stumped. I have attempted
several versions of the attached code, all with the same
result. Help is unfortunately written in an
unintelligible language; your assistance would be greatly
appreciated.
I am attempting to add information in a class named Art
to an arraylist named ArtList with the Button1_click
event.
'** MODULE1 **
Imports System
Imports System.IO
Imports System.Collections
Imports System.Runtime.Serialization.Formatters.Soap
<[Serializable]()> Public Class Art
Public Title As String
Public Des As String
Public Room As String
Public Location As String
Public Value As Integer
Public Bequeth As String
Public Picture As String
End Class
Module Module1
Public ArtList As ArrayList
End Module
' ** FORM1 **
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As
System.Object, _
ByVal e As System.EventArgs) Handles
Button1.Click
Dim myArt As New Object
myArt = New Art
With myArt
.Title = tbTitle.Text
.Des = tbDesc.Text
.Location = tbLocation.Text
.Room = cbRoom.SelectedItem
.Value = tbValue.Text
.Picture = tbPicture.Text
.Bequeth = tbBequeth.Text
End With
ArtList.Add(myArt)
SaveFile()
End Sub
End Class
following error:
An unhandled exception of
type 'System.NullReferenceException' occurred in Art.exe
Additional information: Object reference not set to an
instance of an object.
Being new to VB.Net I'm stumped. I have attempted
several versions of the attached code, all with the same
result. Help is unfortunately written in an
unintelligible language; your assistance would be greatly
appreciated.
I am attempting to add information in a class named Art
to an arraylist named ArtList with the Button1_click
event.
'** MODULE1 **
Imports System
Imports System.IO
Imports System.Collections
Imports System.Runtime.Serialization.Formatters.Soap
<[Serializable]()> Public Class Art
Public Title As String
Public Des As String
Public Room As String
Public Location As String
Public Value As Integer
Public Bequeth As String
Public Picture As String
End Class
Module Module1
Public ArtList As ArrayList
End Module
' ** FORM1 **
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As
System.Object, _
ByVal e As System.EventArgs) Handles
Button1.Click
Dim myArt As New Object
myArt = New Art
With myArt
.Title = tbTitle.Text
.Des = tbDesc.Text
.Location = tbLocation.Text
.Room = cbRoom.SelectedItem
.Value = tbValue.Text
.Picture = tbPicture.Text
.Bequeth = tbBequeth.Text
End With
ArtList.Add(myArt)
SaveFile()
End Sub
End Class