你用以下程序试试你的运行结果是否和我一样:
窗体userform1代码:
- Private Sub CommandButton1_Click()
- Debug.Print "HIDE前mccad的值为:" & mccad
- Debug.Print "HIDE前mjtd 的值为:" & mjtd
- Me.Hide
- Debug.Print "HIDE后mccad的值为:" & mccad
- Debug.Print "HIDE后mjtd 的值为:" & mjtd
- Unload Me
- Debug.Print "卸后mccad的值为:" & mccad
- Debug.Print "卸后mjtd 的值为:" & mjtd
- End Sub
- Private Sub UserForm_Initialize()
- Debug.Print "未设置前mccad的值为:" & mccad
- Debug.Print "未设置前mjtd 的值为:" & mjtd
- mccad = "www.mccad.net"
- mjtd = "www.mjtd.com"
- Debug.Print "打开窗体初始化后mccad的值为:" & mccad
- Debug.Print "打开窗体初始化后mjtd 的值为:" & mjtd
-
- End Sub
模块1代码:
- Public mccad As String
- Public mjtd As String
复制代码
这是我的运行结果:
- 未设置前mccad的值为:
- 未设置前mjtd 的值为:
- 打开窗体初始化后mccad的值为:www.mccad.net
- 打开窗体初始化后mjtd 的值为:www.mjtd.com
- HIDE前mccad的值为:www.mccad.net
- HIDE前mjtd 的值为:www.mjtd.com
- HIDE后mccad的值为:www.mccad.net
- HIDE后mjtd 的值为:www.mjtd.com
- HIDE前mccad的值为:www.mccad.net
- HIDE前mjtd 的值为:www.mjtd.com
- HIDE后mccad的值为:www.mccad.net
- HIDE后mjtd 的值为:www.mjtd.com
- 卸后mccad的值为:www.mccad.net
- 卸后mjtd 的值为:www.mjtd.com
复制代码 |