我想在两个单文档窗口中公用一个变量,这样能实现吗?
有其他可行的方法吗?
谢谢!

解决方案 »

  1.   

    public dim aaa
    或 一个的public action 下个引用.
      

  2.   

    放在Module里面Public a As Integer
      

  3.   

    可以啊,使用public在模块里定义
      

  4.   

    要么在模块里写入Public a As Integer,或者在窗体的声明部分写入Public a As Integer
    然后在别的窗体里用form1.a 引用。
      

  5.   

    还是搞不定!
      我用窗口创建了一个小对话框,有两单选框按钮。
    选择其中一个后,在main主窗口中如何体现?
    对话框中点击ok键:
    Public Sub OK_Click()
    If Option1.Value = True Then
        Main.BL1 = True
        Main.BL2 = False
    ElseIf Option2.Value = True Then
        Main.BL2 = True
        Main.BL1 = False
    End If
    Main.Show
    Unload Me
    End Sub
    主窗口相关代码:
              If BL1 = True Then
              
                    For i = 0 To 24
                       txtInR(i).Locked = False
                       txtWdg(i).Locked = False
                    Next
               ElseIf BL2 = True Then
                    For i = 0 To 11
                       txtHD(i).Locked = False
                       txtWdg2(i).Locked = False
                    Next
               End If
    其中B1,B2为全局变量。程序错那?
    高手指点一下!
    急A \\
      

  6.   

    这样啊 ,你想想,在你的Main窗口还没有显示(在你的这中情况下也就是没有初始化)的 情况下,程序无法知道main窗口的变量,所以,这种情况可以把公用变量定义在模块中就行了。
      

  7.   

    新加一个模块,并将你要用的变量声明为public型