我在尝试调试我的表单时遇到此错误,我无法看到错误在哪里(也没有突出显示在哪里),任何人都有任何建议? An error occurred creating the form. See Exception.InnerException for details. The error is: Obje
An error occurred creating the form.
See Exception.InnerException for
details. The error is: Object
reference not set to an instance of an
object.
Dim dateCrap As String = "Date:" Dim IPcrap As String = "Ip:" Dim pcCrap As String = "Computer:" Dim programCrap As String = "Program:" Dim textz As String Dim sep() As String = {vbNewLine & vbNewLine} Dim sections() As String = Text.Split(sep, StringSplitOptions.None) Dim NewArray() As String = TextBox1.Text.Split(vbNewLine) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load textz = TextBox1.Text End Sub错误在这里:
Dim textz As String = TextBox1.Text
和这里:
Dim NewArray() As String = TextBox1.Text.Split(vbNewLine)
可能在这里:
Dim sections() As String = Text.Split(sep, StringSplitOptions.None)
你不能初始化这样的成员,因为这个代码基本上是在构造函数中执行的,在TextBox1(或任何其他控件/属性)初始化之前,因此它是Nothing.
将所有引用控件的初始化放在Form_Load事件中 – 这就是它的用途.