2010-06-10
展开全部
shape:控件数组,index属性是0 到 5
然后用随机函数产生数组索引
把以下代码稍作修改就可以达到你要的效果:
Dim i As Integer
Private Sub Command1_Click()
Dim Sindex As Integer
For i = 0 To 4
Shape1(i).Visible = False
Next i
Randomize
Sindex = Int(Rnd() * 5) '产生0~4之间的随即整数
Shape1(Sindex).Visible = True
Randomize
Sindex = Int(Rnd() * 5) '产生0~4之间的随即整数
Shape1(Sindex).Visible = True
Randomize
Sindex = Int(Rnd() * 5) '产生0~4之间的随即整数
Shape1(Sindex).Visible = True
End Sub
Private Sub Form_Load()
For i = 0 To 4
Shape1(i).Visible = False
Next i
End Sub
然后用随机函数产生数组索引
把以下代码稍作修改就可以达到你要的效果:
Dim i As Integer
Private Sub Command1_Click()
Dim Sindex As Integer
For i = 0 To 4
Shape1(i).Visible = False
Next i
Randomize
Sindex = Int(Rnd() * 5) '产生0~4之间的随即整数
Shape1(Sindex).Visible = True
Randomize
Sindex = Int(Rnd() * 5) '产生0~4之间的随即整数
Shape1(Sindex).Visible = True
Randomize
Sindex = Int(Rnd() * 5) '产生0~4之间的随即整数
Shape1(Sindex).Visible = True
End Sub
Private Sub Form_Load()
For i = 0 To 4
Shape1(i).Visible = False
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询