关于image的一点小问题,请看代码,在线等,解决给分
我的本意是用鼠标左键在imageCard控件数组中点击,如果被点击的imageCard就把top值改变,但是我写了下面代码后用左键点击没用,只能用右键才行,请问应该如何来写?
Private Sub imageCard_Click(Index As Integer)
If Index < 21 Then
Dim tmpstrArr() As String
tmpstrArr() = Split(imageCard(Index).Tag, ", ")
If tmpstrArr(1) = "false " Then
imageCard(Index).Top = imageCard(Index).Top - 500
imageCard(Index).Tag = tmpstrArr(0) & ",true "
End If
If tmpstrArr(1) = "true " Then
imageCard(Index).Top = imageCard(Index).Top + 500
imageCard(Index).Tag = tmpstrArr(0) & ",false "
End If
'MsgBox imageCard(Index).Tag
Erase tmpstrArr
End If
End Sub
[解决办法]
用mousedown 或mouseup事件代替click事件
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then MsgBox "OK "
End Sub
[解决办法]
Private Sub Form_Load()
Static n As Integer
If n = 0 Then n = 1
If n <> 0 Then Load Label1(n)
Label1(n).Move 300, 200 + n * 500
' Label1(n).Caption = "Label1( " & n & ") "
Label1(n).Caption = InputBox( "請輸入名字: ")
Label1(n).Visible = True
Label1(n).Tag = "asdfasdf "
n = n + 1
End Sub
Private Sub Label1_Click(Index As Integer)
MsgBox Index
Unload Label1(Index)
End Sub
給你例子
[解决办法]
如果程序imagecard是load加载的话用楼上的方法就行了.若是用control.add方法就把要加载的控件写成类,再来调用.在类里写在控件的事件,用CallByName来返回你在窗体上写的函数.