以另一种形式调用Sub的问题 [英] Problem calling a Sub in another form
本文介绍了以另一种形式调用Sub的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好。
我有2个表格(Form1和Form2)。当我从
form2调用form1中的Sub时,我得到错误对象引用未设置为对象的实例
!
我该怎么做才能解决问题?
谢谢
解决方案
请发布代码那个叫子。
谢谢,
Seth Rowe
vitorjol写道:
你好。
我有2个表格(Form1和Form2)。当我从
form2调用form1中的Sub时,我得到错误对象引用未设置为对象的实例
!
我该怎么做才能解决问题?
谢谢
这是代码:<
''form2中的代码
Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object,ByVal
$ b $ as As System.Windows.Forms。 DataGridViewCellMouseEventArg s)句柄
DataGridView1.RowHeaderMouseClick
dim exitvar as Integer
exitvar = DataGridView1.Rows(e.RowIndex).Cells(0) .Value
Dim ff As New Form1
ff.BringToFront()
ff.soumavez(exitvar)''这是对Form1中的sub
End Sub
" rowe_newsgroups"写道:
请发布调用该子代码。
谢谢,
Seth Rowe
vitorjol写道:
你好。
我有2个表单(Form1和Form2)。当我从
form2调用form1中的Sub时,我得到错误对象引用未设置为对象的实例
!
我该怎么做才能解决问题?
谢谢
< blockquote>看起来它应该工作,当你单步执行代码时,
发生异常?如果错误发生在除此
sub之外的其他地方,请发布该代码。 soumavez是什么呢?是什么意思?
谢谢,
Seth Rowe
vitorjol写道:
这是代码:
''form2中的代码
Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object,ByVal
$ b $ as As System.Windows.Forms.DataGridViewCellMouseEventArg s)句柄
DataGridView1.RowHeaderMouseClick
dim exitvar as Integer
exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
Dim ff As New Form1
ff.BringToFront()
ff .soumavez(exitvar)''这是对Form1中sub的调用
End Sub
" rowe_newsgroups"写道:
请发布调用该子代码。
谢谢,
Seth Rowe
vitorjol写道:
你好。
>
我有2个表单(Form1和Form2)。当我从
form2调用form1中的Sub时,我得到错误对象引用未设置为对象的实例
!
我该怎么做才能解决问题?
>
谢谢
Hello.
I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
form2, i get the error "object reference not set to an instance of an object"
!
What can i do to solve the problem?
Thanks
解决方案
Please post the code that calls the sub.
Thanks,
Seth Rowe
vitorjol wrote:Hello.
I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
form2, i get the error "object reference not set to an instance of an object"
!
What can i do to solve the problem?
Thanks
Here is the code:
'' the code in form2
Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal
e As System.Windows.Forms.DataGridViewCellMouseEventArg s) Handles
DataGridView1.RowHeaderMouseClick
dim exitvar as Integer
exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
Dim ff As New Form1
ff.BringToFront()
ff.soumavez(exitvar) '' this is the call to the sub in Form1
End Sub
"rowe_newsgroups" wrote:
Please post the code that calls the sub.
Thanks,
Seth Rowe
vitorjol wrote:Hello.
I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
form2, i get the error "object reference not set to an instance of an object"
!
What can i do to solve the problem?
Thanks
Looks like it should work, when you step through the code where does
the exception occur? If the error occurs in somewhere other than this
sub please post that code too. Also what does "soumavez" mean?
Thanks,
Seth Rowe
vitorjol wrote:Here is the code:
'' the code in form2
Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal
e As System.Windows.Forms.DataGridViewCellMouseEventArg s) Handles
DataGridView1.RowHeaderMouseClick
dim exitvar as Integer
exitvar = DataGridView1.Rows(e.RowIndex).Cells(0).Value
Dim ff As New Form1
ff.BringToFront()
ff.soumavez(exitvar) '' this is the call to the sub in Form1
End Sub
"rowe_newsgroups" wrote:
Please post the code that calls the sub.
Thanks,
Seth Rowe
vitorjol wrote:Hello.
>
I have 2 forms (Form1 and Form2). When i call the Sub placed in form1 from
form2, i get the error "object reference not set to an instance of an object"
!
What can i do to solve the problem?
>
Thanks
这篇关于以另一种形式调用Sub的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文