Private Sub picBox_Click(Index As Integer) select case index case 0 case 1 . . . end select end sub
我建议你把变量的数目放在函数变量中 Private Sub CreatPic(ConCou As Integer) Load picBox(ConCou) With picBox(ConCou) .Visible = True .Enabled = True .Caption = "图片控件" & ConCou End With End Sub
Option Explicit Dim Cou As IntegerPrivate Sub CreatPic() Cou = Cou + 1 Load picBox(Cou) With picBox(Cou) .Visible = True .Enabled = True Print "图片控件" & Cou End With End SubPrivate Sub Command1_Click() CreatPic End SubPrivate Sub picBox_Click(Index As Integer) Debug.Print "click" End Sub'运行是可以响应事件的
Option Explicit Dim Cou As IntegerPrivate Sub CreatPic() Cou = Cou + 1 Load Picbox(Cou) With Picbox(Cou) .Visible = True .Enabled = True .Left = Cou * 1000 '.Caption = "图片控件" & Cou--------->picbox没该属性 End With End SubPrivate Sub Command1_Click() CreatPic Picbox_Click (Cou) End SubPrivate Sub Form_Load() Cou = 0 End SubPrivate Sub Picbox_Click(Index As Integer) MsgBox Picbox(Index).Left End Sub
select case index
case 0
...case 2...
case 3
...end select不知道这样行不行?
行的话给我点分,要不我提问不了了!
但像mousemove事件却响应啊。。我为些郁闷了两天了。。
select case index
case 0
case 1
.
.
.
end select
end sub
Private Sub CreatPic(ConCou As Integer)
Load picBox(ConCou)
With picBox(ConCou)
.Visible = True
.Enabled = True
.Caption = "图片控件" & ConCou
End With
End Sub
Dim Cou As IntegerPrivate Sub CreatPic()
Cou = Cou + 1
Load picBox(Cou)
With picBox(Cou)
.Visible = True
.Enabled = True
Print "图片控件" & Cou
End With
End SubPrivate Sub Command1_Click()
CreatPic
End SubPrivate Sub picBox_Click(Index As Integer)
Debug.Print "click"
End Sub'运行是可以响应事件的
Dim Cou As IntegerPrivate Sub CreatPic()
Cou = Cou + 1
Load Picbox(Cou)
With Picbox(Cou)
.Visible = True
.Enabled = True
.Left = Cou * 1000
'.Caption = "图片控件" & Cou--------->picbox没该属性
End With
End SubPrivate Sub Command1_Click()
CreatPic
Picbox_Click (Cou)
End SubPrivate Sub Form_Load()
Cou = 0
End SubPrivate Sub Picbox_Click(Index As Integer)
MsgBox Picbox(Index).Left
End Sub
要不然所有的PictureBox叠在一起