VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "猜数游戏"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "猜数"
      Height          =   495
      Left            =   2400
      TabIndex        =   1
      Top             =   1920
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "计算机选数"
      Height          =   495
      Left            =   720
      TabIndex        =   0
      Top             =   1920
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim A As Integer, N As Integer, M As Integer
Private Sub Command1_Click()
    Randomize
    M = Int(Rnd() * 10)         '随机生成正整数M
    N = 0                       '猜数次数
    Cls
    Print "计算机已选好0～10的一个数，请猜"
End Sub
Private Sub Command2_Click()
    A = InputBox("请输入你猜的数")
    N = N + 1
    If A = M Then
        Print "你猜的是" & A & "，恭喜你猜对了，你共猜了" & N & "次"
    Else
        If A > M Then
            Print "你猜的是" & A & "，大了，这是你的第" & N & "次猜数"
        Else
            Print "你猜的是" & A & "，小了，这是你的第" & N & "次猜数"
        End If
    End If
End Sub

