1在窗體上放10個Image控件,為控件組(image1(0),image1(1),image1(2)……)
2將image控件的picture屬性設好
3編寫代碼效果:點擊鼠標可隨意選中一張圖片:
Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
For i=0 to Image1.Count-1
If Image1(i). BorderStyle=1 then
Image1(i). BorderStyle=0
End If
Image1(index).BorderStyle=1
Next
我的問題是:在同一個程序內還有另外一個窗體,也有多個image控件,我現在要做相同的效果.我想在module中來寫一個子過程或函數.然后在Form的Image1_MouseDown中來調用.可是具體應該怎麼寫,我怎麼也寫不正確,哪位高手幫幫忙.
2將image控件的picture屬性設好
3編寫代碼效果:點擊鼠標可隨意選中一張圖片:
Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
For i=0 to Image1.Count-1
If Image1(i). BorderStyle=1 then
Image1(i). BorderStyle=0
End If
Image1(index).BorderStyle=1
Next
我的問題是:在同一個程序內還有另外一個窗體,也有多個image控件,我現在要做相同的效果.我想在module中來寫一個子過程或函數.然后在Form的Image1_MouseDown中來調用.可是具體應該怎麼寫,我怎麼也寫不正確,哪位高手幫幫忙.
dim i as long
For i=0 to ob.Image1.Count-1
If ob.Image1(i). BorderStyle=1 then
ob.Image1(i). BorderStyle=0
End If
ob.Image1(index).BorderStyle=1
Next
End Sub
'在调用的时候就:Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
abc form1,index'把窗体跟索引当参数传进去
end sub
Public Sub SetImgSelect(byval frmTarget as Object,byval index as integer)
with frmTarget
For i=0 to .Image1.Count-1
If .Image1(i). BorderStyle=1 then
.Image1(i). BorderStyle=0
End If
Next
.Image1(index).BorderStyle=1
End With
end sub
在窗体事件中这么写
Private Sub Image1_MouseDown ...
SetImgSelect me,index
end sub