Why does the code pasted below throw me a Null Reference Exception? Because I simply can't seem to find out why.
Note: The textboxes have the correct names & they aren't empty when I get the exception.
My code: (I've highlighted the line with the error)
txtGuid.BackColor = Color.White
txtName.BackColor = Color.White
If txtGuid.Text <> "" And txtName.Text <> "" Then
Dim name As String = txtName.Text
Dim guid As String = txtGuid.Text
**frmWhitelist.names.Add(name)**
frmWhitelist.guids.Add(guid)
Me.Close()
Else
If txtGuid.Text = "" Then
txtGuid.BackColor = Color.Red
End If
If txtName.Text = "" Then
txtName.BackColor = Color.Red
End If
lblError.Text = "Please check your input in the red-colored fields."
End If
Call stack:
> DayZAdminApp.exe!DayZAdminApp.inptBoxWhitelist.btnOk_Click(Object sender, System.EventArgs e) Line 15 + 0x3d bytes Basic
While debugging, the txtGuid.text
and txtName.text
both have text values in my Locals tab.
PS: If this is caused by the fact that I'm trying 2 add items to a public var on another form, how can I work around this?
PPS: The frmWhitelist.names
and frmWhitelist.guids
are declared as such:
Public names, guids As List(Of String)