VB程序设计,label控件数组为什么只能控制第一个
初学实在不明白哪里出了问题代码如下PrivateSubLabel1_MouseMove(indexAsInteger,ButtonAsInteger,ShiftAsInt...
初学实在不明白哪里出了问题
代码如下
Private Sub Label1_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Label1(index).FontSize = 9 Then Label1(index).FontSize = 20
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Label1(index).FontSize > 9 Then Label1(index).FontSize = 9
End Sub
为什么只有label1(0)可以变大缩小,其余的只能变大?
label的caption是1、2、3……
谢谢! 展开
代码如下
Private Sub Label1_MouseMove(index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Label1(index).FontSize = 9 Then Label1(index).FontSize = 20
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Label1(index).FontSize > 9 Then Label1(index).FontSize = 9
End Sub
为什么只有label1(0)可以变大缩小,其余的只能变大?
label的caption是1、2、3……
谢谢! 展开
1个回答
展开全部
你试试下面这样,原因是第二段程序,你看有没有index值?没有吧,那index不就是0吗,不就是只有第一个会变小啊,对不对。
Option Explicit
Dim tip
Private Sub Label1_MouseMove(index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
tip = index
If Label1(tip).FontSize = 9 Then Label1(index).FontSize = 20
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
If Label1(tip).FontSize > 9 Then Label1(tip).FontSize = 9
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询