vb.net – 创建表单时出错.有关详细信息,请参阅Exception.InnerException.错误是:对象引用未设置为对象的实例

vb.net – 创建表单时出错.有关详细信息,请参阅Exception.InnerException.错误是:对象引用未设置为对象的实例,第1张

概述我在尝试调试我的表单时遇到此错误,我无法看到错误在哪里(也没有突出显示在哪里),任何人都有任何建议? An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. Di 我在尝试调试我的表单时遇到此错误,我无法看到错误在哪里(也没有突出显示在哪里),任何人都有任何建议?

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 StringDim 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.TextEnd 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事件中 – 这就是它的用途.

总结

以上是内存溢出为你收集整理的vb.net – 创建表单时出错.有关详细信息,请参阅Exception.InnerException.错误是:对象引用未设置为对象的实例全部内容,希望文章能够帮你解决vb.net – 创建表单时出错.有关详细信息,请参阅Exception.InnerException.错误是:对象引用未设置为对象的实例所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1236057.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存