花一个下午写的21点游戏
头晕了,出去逛一下再回来继续
发上来大家帮忙指点错误出来
'21 点游戏的开发
'单机人机游戏。双方轮流要点数,也可以选择任意时刻停止。双方都停止后计算各自总点数,
'超过21点者为败,都没超过或都超过21点时,总点数更靠近21点者为胜。总点数一样时,人胜。
'一共可要7次。电脑在点数大于16点时,则停止要点。在窗体上,上面显示电脑的数字和总点数,
'下面显示人的总点数和数字?
Dim i As Integer
Dim k As Integer
Dim x As Integer
Dim y As Integer
Dim m As Integer
Dim n As Integer
Private Sub Command1_Click()
x = Int(Rnd * 10)
y = Int(Rnd * 10)
i = i + 1
If i > 7 Then GoTo line1
If m <= 16 Then
Form1.Label1(i).Caption = x
m = m + x
Else
GoTo line1
End If
If n < 21 Then
Form1.Label2(i).Caption = y
n = n + y
End If
Form1.Label3.Caption = m
Form1.Label4.Caption = n
line1:
If m > 21 Then
If n > 21 Then
If (m - 21) >= (n - 21) Then
Form1.Label5 = "人脑赢了"
Else
Form1.Label5 = "电脑赢了"
End If
ElseIf n = 21 Then
Form1.Label5 = "人脑赢了"
ElseIf n < 21 Then
Form1.Label5 = "人脑赢了"
End If
ElseIf m = 21 Then
If n = 21 Then
Form1.Label5 = "人脑赢了"
Else
Form1.Label5 = "电脑赢了"
End If
ElseIf m < 21 Then
If n > 21 Then
Form1.Label5 = "电脑赢了"
ElseIf n = 21 Then
Form1.Label5 = "人脑赢了"
ElseIf n < 21 Then
If (21 - m) < (21 - n) Then
Form1.Label5 = "电脑赢了"
Else
Form1.Label5 = "人脑赢了"
End If
End If
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Randomize
Form1.Show
i = 0
End Sub
Private Sub Text2_Change()
End Sub