当前位置 : 主页 > 编程语言 > c语言 >

vb.net – 创建表单时出错.有关详细信息,请参阅Exception.InnerException.错误是:对象

来源:互联网 收集:自由互联 发布时间:2021-06-24
我在尝试调试我的表单时遇到此错误,我无法看到错误在哪里(也没有突出显示在哪里),任何人都有任何建议? 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事件中 – 这就是它的用途.

网友评论