VB6怎么简化这些代码?我控件越多,代码就越多,怎么简化??

在下新人,想问下VB6怎么简化以下代码..PrivateSub图1_Click()Me.WindowState=1EndSubPrivateSub图1_Mousedown... 在下新人,想问下VB6怎么简化以下代码..
Private Sub 图1_Click()
Me.WindowState = 1
End Sub
Private Sub 图1_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
图1.Picture = LoadResPicture(101, vbResBitmap)
End Sub
Private Sub 图1_Mouseup(Button As Integer, Shift As Integer, X As Single, Y As Single)
图1.Picture = LoadPicture()
End Sub
'-------------------------
Private Sub 图2_Click()
End
End Sub
Private Sub 图2_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
图2.Picture = LoadResPicture(102, vbResBitmap)
End Sub
Private Sub 图2_Mouseup(Button As Integer, Shift As Integer, X As Single, Y As Single)
图2.Picture = LoadPicture()
End Sub
'--------------------------
Private Sub 图3_Click()
'其他
End Sub
Private Sub 图3_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
图3.Picture = LoadResPicture(103, vbResBitmap)
End Sub
Private Sub 图3_Mouseup(Button As Integer, Shift As Integer, X As Single, Y As Single)
图3.Picture = LoadPicture()
End Sub
展开
 我来答
百度网友bdb9803
2011-11-27 · TA获得超过1.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:53%
帮助的人:1亿
展开全部
相同处理方法的控件可以形成控件数组,这样只要一个事件就可以处理所有控件
追问
要怎么做?不会给个例子或代码吧...
追答
Private Sub 图_Click(Index As Integer)
Select Case Index
Case 0
Me.WindowState = 1
Case 1
End
Case 2
'其他
End Select
End Sub

Private Sub 图_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
图1.Picture = LoadResPicture(101 + Index, vbResBitmap)
End Sub

Private Sub 图_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
图.Picture = LoadPicture()
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式