求助VB程序编写
发布网友
发布时间:2022-12-21 07:21
我来回答
共1个回答
热心网友
时间:2023-10-08 00:30
Dim Big As Boolean
Private Sub Form_Load()
roll.Enabled = False
play.Enabled = True
gpb.Caption = "请按Play掷骰子"
End Sub
Private Sub play_Click()
Dim x As Long, y As Long
Randomize
x = CInt(Rnd() * 5 + 1)
y = CInt(Rnd() * 5 + 1)
If x + y > 6 Then
Big = True
gpb.Caption = "点数为大"
Else
Big = False
gpb.Caption = "点数为小"
End If
play.Enabled = False
roll.Enabled = True
End Sub
Private Sub roll_Click()
Dim x As Long, y As Long
Randomize
x = CInt(Rnd() * 5 + 1)
y = CInt(Rnd() * 5 + 1)
If x + y > 6 Then
If Big = True Then
gpb.Caption = "你赢了"
Else
gpb.Caption = "你输了"
End If
Else
If Big = True Then
gpb.Caption = "你输了"
Else
gpb.Caption = "你赢了"
End If
End If
play.Enabled = True
roll.Enabled = False
End Sub