[求助]如何在form2中使用form1的变量? vb.net2005

hunter_001 2008-04-12 10:30:02
[求助]如何在form2中使用form1的变量?
Public Class main
Inherits System.Windows.Forms.Form
Public ioDmm1 As Ivi.Visa.Interop.FormattedIO488 '声明测量标准
Public ioDmm2 As Ivi.Visa.Interop.FormattedIO488 '声明被测仪器
......
......

'初始化测量标准I/O
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mgr1 As Ivi.Visa.Interop.ResourceManager
Dim ioAddress1 As String
On Error GoTo ioError
ioAddress1 = Txtaddress1.Text

If Len(ioAddress1) > 6 Then
Txtaddress1.Text = ioAddress1
mgr1 = New Ivi.Visa.Interop.ResourceManager
ioDmm1 = New Ivi.Visa.Interop.FormattedIO488
ioDmm1.IO() = mgr1.Open(ioAddress1)
EnableControl1(True)
End If

Exit Sub
ioError:
MsgBox("InitIO Error:" & vbCrLf & Err.Description)
End Sub



Public Class _34401A

sub ()
main.ioDmm2 = New Ivi.Visa.Interop.FormattedIO488

ioDmm1.WriteString("5720A scpicmd") '初始化设置5720A

main.ioDmm2.WriteString("*RST") ' Reset the dmm
main.ioDmm2.WriteString("*CLS")

end sub


如上,main中定义的 iodmm1、iodmm2,怎么在_34401A中使用?
我用main.ioDmm2.WriteString("*RST") 试了,不行,无返回信号。
...全文
184 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
knowledge_Is_Life 2008-05-01
  • 打赏
  • 举报
回复
没遇到过这种情况.
meimen2 2008-04-15
  • 打赏
  • 举报
回复
学习
  • 打赏
  • 举报
回复
传递窗口对象过去就可以了
jikun6666 2008-04-14
  • 打赏
  • 举报
回复
用这个方法试试传递到第三个窗体时看看呢。
hunter_001 2008-04-12
  • 打赏
  • 举报
回复
解决了,多写了一行(main.ioDmm2 = New Ivi.Visa.Interop.FormattedIO488 ),迷糊了,呵呵,主要还是新手,好多不知道。

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧