先自己画控件,参照图片里面的
不能有错
注意左边框架里面还有一个标签
不要忘记!!
Private Sub Command1_Click()
Randomize
Dim a%, b%, c%, cr%
cr = Int(3 * Rnd + 1)
If cr = 1 Then
Label1.Caption = "石头"
ElseIf cr = 2 Then
Label1.Caption = "剪刀"
ElseIf cr = 3 Then
Label1.Caption = "布"
End If
If cr = 1 And Option1.Value = True Then MsgBox ("平")
If cr = 1 And Option2.Value = True Then MsgBox ("You Lost")
If cr = 1 And Option3.Value = True Then MsgBox ("You Win!")
If cr = 2 And Option1.Value = True Then MsgBox ("You Win!")
If cr = 2 And Option2.Value = True Then MsgBox ("平")
If cr = 2 And Option3.Value = True Then MsgBox ("You Lost")
If cr = 3 And Option1.Value = True Then MsgBox ("You Lost")
If cr = 3 And Option2.Value = True Then MsgBox ("You Win!")
If cr = 3 And Option3.Value = True Then MsgBox ("平")
End Sub
Private Sub Command2_Click()
Unload Form1
End Sub
Private Sub Label3_Click()
End Sub
Private Sub Command3_Click()
MsgBox ("You Win!" & w & Chr(13) & "You Lost" & l & Chr(13) & "平" & p)
End Sub
Private Sub Form_Load()
Label1.FontSize = 65
End Sub
Private Sub Option1_Click()
Command1.SetFocus
End Sub
Private Sub Option2_Click()
Command1.SetFocus
End Sub
Private Sub Option3_Click()
Command1.SetFocus
End Sub
虽然写的不是很简洁,不过也还OK啦
呵呵
开三个按钮,分别用图片显示,三个按钮值分别为1.2.3.用户点击按钮同是产生一个电脑的随机数,*3.取整,小于一的值为一.小于二的为二,小于三的为三.然后把两个数值用case语句来判断.
over~!!!!!
设四个按钮分别是石头剪刀布和开始并命名为s,j,b,k,两个lable一个显示电脑出什么一个显示结果下面是代码:
Dim a As Single '通用里
Private Sub b_Click()
a = 3
End Sub
Private Sub j_Click()
a = 2
End Sub
Private Sub k_Click()
Randomize
Dim b As Integer
b = Int(Rnd() * 3) + 1
Print b
Select Case b
Case 1
Label1.Caption = "石头"
If a = 1 Then Label2.Caption = "平局" Else If a = 2 Then Label2.Caption = "你输了" Else Label2.Caption = "你赢了"
Case 2
Label1.Caption = "剪刀"
If a = 1 Then Label2.Caption = "你赢了" Else If a = 2 Then Label2.Caption = "平局" Else Label2.Caption = "你输了"
Case 3
Label1.Caption = "布"
If a = 1 Then Label2.Caption = "你输了" Else If a = 2 Then Label2.Caption = "你赢了" Else Label2.Caption = "平局"
End Select
End Sub
Private Sub s_Click()
a = 1
End Sub
我if不喜欢用转行的
int(rnd()*3+1)