Private Sub Command1_Click()
Label1.Caption = sj ‘计算机随机产生一个值
Label2.Caption = Command1.Caption
If cp(Label1.Caption, Label2.Caption) Then ‘判断胜负
= "乙方负"
Else
Label3.Caption = "乙方胜"
End If
End Sub
Function sj() As String '随机生成石头、剪刀、布
i = ‘随机生成1~3任一整数
If i = 1 Then sj = "石头"
If i = 2 Then sj = "剪刀"
If i = 3 Then sj = "布"
End Function