求助 一个很菜的问题,求个稍微懂vb的回答一下
Private Sub Image1_Click()
image4numb = 1
image4numb2 = 2
End Sub
Private Sub Image2_Click()
image4numb = 2
image4numb2 = 2
End Sub
Public Sub Image2_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
msgbox image4numb
msgbox image4numb2
-------------------------------------------------------------------------------------
如上代码,两个msgbox输出都是空白,也就是说这三块程序的变量值是毫不相干的。
怎样的才能使 第三部分的msgbox输出 前两个事件中的 image4numb和image4numb2的值。
变量 vb 全局
[解决办法]
在窗体代码最上方,定义image4numb和image4numb2
Dim image4numb As Integer
Dim image4numb2 As Integer
Private Sub Image1_Click()
image4numb = 1
image4numb2 = 2
End Sub
Private Sub Image2_Click()
image4numb = 2
image4numb2 = 2
End Sub
Public Sub Image2_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
MsgBox image4numb
MsgBox image4numb2
End Sub