设计

需要label数组,用复制粘贴的方式实现
要添加一个timer,属性设置如下:
vb 五位抽奖程序
vb 五位抽奖程序

运行效果

vb 五位抽奖程序

代码

vb 五位抽奖程序

Private Sub Command1_Click()
    Timer1.Enabled = True
    Command2.Enabled = True
    Command1.Enabled = False
End Sub

Private Sub Command2_Click()
    Timer1.Enabled = False
    Text1.Text = Label2(0).Caption & " " & Label2(1).Caption & " " & Label2(2).Caption & " " & Label2(3).Caption & " " & Label2(4).Caption
    Command2.Enabled = False
    Command1.Enabled = True
    Command3.Enabled = True

End Sub

Private Sub Command3_Click()
    End
End Sub

Private Sub Timer1_Timer()
    Randomize
    Label2(0).Caption = Int(Rnd * 10 + 0)
    Label2(1).Caption = Int(Rnd * 10 + 0)
    Label2(2).Caption = Int(Rnd * 10 + 0)
    Label2(3).Caption = Int(Rnd * 10 + 0)
    Label2(4).Caption = Int(Rnd * 10 + 0)
    
End Sub

相关文章: