你调用的对象是空的。请帮忙! [英] Object reference not set to an instance of an object. Please help!
本文介绍了你调用的对象是空的。请帮忙!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的程序编译好了但是当我点击一个控件来执行它时:
Public Sub numberUpdate(ByVal theNum As Integer)
lblCurrentQuestionNumber.Text = theNum
结束子
我得到这个错误消息:System.NullReferenceException:对象引用未设置为对象的实例。
任何人都可以帮我这个吗?
Hi, my program compiles ok but when I click on a the control to execute this:
Public Sub numberUpdate(ByVal theNum As Integer)
lblCurrentQuestionNumber.Text = theNum
End Sub
I get this error message: System.NullReferenceException: Object reference not set to an instance of an object.
Can anyone help me with this please?
推荐答案
在将值传递给函数之前,需要为该值赋值。
例如:
theNum = 123
You need to assign a value to theNum before passing it to the function.
For example:
theNum = 123
你能在这里指出你如何调用上面的方法吗?这将有助于描述问题。
Can you point here how you are calling above method? That will be helpful to describe the problem.
这是我的代码看起来像我正在调用的:
Dim x as _default
x = New _default
Dim intSentNum As Integer
intSentNum = 1
x.numberUpdate(intSentNum)
这里是我打电话的子项:
Public Sub numberUpdate(ByVal inComingNum As Integer)
>
lblCurrentQuestionNumber.Text = inComingNum
结束子
出于某种原因,我得到相同的对象参考错误消息。
Here is what my code looks like that I''m using to call:
Dim x As _default
x = New _default
Dim intSentNum As Integer
intSentNum = 1
x.numberUpdate(intSentNum)
Here''s the sub that I call:
Public Sub numberUpdate(ByVal inComingNum As Integer)
lblCurrentQuestionNumber.Text = inComingNum
End Sub
For some reason, I get the same object reference error message.
这篇关于你调用的对象是空的。请帮忙!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文