-1
當我去調試我的項目在Visual Basic中,我得到它說的錯誤消息:VB調試錯誤
An unhandled exception of type 'System.InvalidOperationException' occurred in Name Database.exe
Additional information: An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.
這裏是我的代碼:
Public Class Form1
Dim member As String = TextBoxName.Text
Private Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles ButtonAdd.Click
ListBoxName.Items.Add(member & " " & TextBoxDate.Text)
TextBoxDate.Text = ""
TextBoxName.Text = ""
End Sub
Private Sub ButtonRemove_Click(sender As Object, e As EventArgs) Handles ButtonRemove.Click
ListBoxName.Items.Remove(ListBoxName.SelectedItem)
End Sub
Private Sub ButtonCheck_Click(sender As Object, e As EventArgs) Handles ButtonCheck.Click
If ListBoxName.Items.Contains(member & " " & Date.Today.ToString) Then
MsgBox(ListBoxName.Items.Contains(Date.Today.ToString) & "membership needs to be renewed")
End If
End Sub
End Class
讀取內部異常堆棧跟蹤。 – SLaks
這可能是錯誤:'Dim member As String = TextBoxName.Text'表單尚未創建(不是任何控件),但是您引用了其中一個控件(這不是任何控件)。聲明它,但不要初始化('member = ...'),直到FormLoad – Plutonix
什麼是「內部異常堆棧跟蹤」? – user3267723