⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 game.frm

📁 用vb编的猜数字的小游戏
💻 FRM
📖 第 1 页 / 共 4 页
字号:
      BackColor       =   &H00C0C0C0&
      Caption         =   "4"
      BeginProperty Font 
         Name            =   "Fixedsys"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   3
      Left            =   5760
      TabIndex        =   22
      Top             =   1200
      Width           =   255
   End
   Begin VB.Label Label2 
      BackColor       =   &H00C0C0C0&
      Caption         =   "3"
      BeginProperty Font 
         Name            =   "Fixedsys"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   2
      Left            =   5760
      TabIndex        =   21
      Top             =   840
      Width           =   255
   End
   Begin VB.Label Label2 
      BackColor       =   &H00C0C0C0&
      Caption         =   "2"
      BeginProperty Font 
         Name            =   "Fixedsys"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   1
      Left            =   5760
      TabIndex        =   20
      Top             =   480
      Width           =   255
   End
   Begin VB.Label Label2 
      BackColor       =   &H00C0C0C0&
      Caption         =   "1"
      BeginProperty Font 
         Name            =   "Fixedsys"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   0
      Left            =   5760
      TabIndex        =   19
      Top             =   120
      Width           =   255
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0C0C0&
      Caption         =   "总共用了"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3720
      TabIndex        =   18
      Top             =   4440
      Width           =   735
   End
   Begin VB.Menu Option 
      Caption         =   "游戏选项设置(&O)"
      Begin VB.Menu Restart 
         Caption         =   "重新开局(&R)"
         Shortcut        =   {F2}
      End
      Begin VB.Menu Levelset 
         Caption         =   "难度级别(&L)"
         Begin VB.Menu Basic 
            Caption         =   "初级(&B)"
            Checked         =   -1  'True
         End
         Begin VB.Menu Expert 
            Caption         =   "高级(&E)"
            Checked         =   -1  'True
         End
      End
      Begin VB.Menu split 
         Caption         =   "-"
      End
      Begin VB.Menu Exit 
         Caption         =   "退出(&X)"
      End
   End
   Begin VB.Menu help 
      Caption         =   "帮助(&H)"
      Begin VB.Menu gamehelp 
         Caption         =   "游戏介绍(&G)"
         Shortcut        =   {F1}
      End
      Begin VB.Menu Result 
         Caption         =   "正确答案(&A)"
         Shortcut        =   {F3}
      End
      Begin VB.Menu split1 
         Caption         =   "-"
      End
      Begin VB.Menu about 
         Caption         =   "关于(&B)"
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public F

Private Sub about_Click()
frmAbout.Show
End Sub

Private Sub Basic_Click()
Basic.Checked = True: Expert.Checked = False
Option1.Value = True
Option2.Value = False
End Sub

Private Sub Command1_Click()
Restart_Click
End Sub

Private Sub Command13_Click()
Result_Click
End Sub

Private Sub Command14_Click()
Unload Me
End
End Sub

Private Sub Command2_Click()
If Text1.Text = "请输入一个四位数" Or Text1.Text = "" Or Len(Text1) < 4 Then
GoTo Secline
End If
Dim A, B, C, D, G, J, K, L, M, N, O, red, blue
If F = 11 And Text1 <> Text3 Then
Dialog1.Show: GoTo Lastline
End If
A = Val(Left(Text1, 1))
B = Val(Mid(Text1, 2, 1))
C = Val(Mid(Text1, 3, 1))
D = Val(Right(Text1, 1))
J = Val(Left(Text3, 1))
K = Val(Mid(Text3, 2, 1))
L = Val(Mid(Text3, 3, 1))
M = Val(Right(Text3, 1))
If Text1 = Text3 Then
Text2(F) = Text1
For G = 0 To 3
Shape1(G + (F * 4)).FillColor = RGB(255, 255, 0)
Next G
Label3.Caption = F + 1
Dialog.Show
  If F + 1 > 0 And F + 1 < 8 Then
  Dialog.Label1.Caption = "    祝贺您!只用了"
  Dialog.Label2.Caption = F + 1
  Dialog.Label3.Caption = "步就算出来了!"
  ElseIf F + 1 >= 8 And F + 1 < 10 Then
  Dialog.Label1.Caption = "    还不错!但用了"
  Dialog.Label2.Caption = F + 1
  Dialog.Label3.Caption = "步,下回继续努力!"
  ElseIf F >= 10 And F <= 12 Then
  Dialog.Label1.Caption = "得加油啊!已经用了"
  Dialog.Label2.Caption = F + 1
  Dialog.Label3.Caption = "步了,不过还有机会!"
  End If
GoTo Lastline
End If
  If A = J Then
    red = 1
  End If
  If B = K Then
    red = red + 1
  End If
  If C = L Then
    red = red + 1
  End If
  If D = M Then
    red = red + 1
  End If
  If A = K And A <> B And A <> C And A <> D Then
    blue = 1
  End If
  If A = L And A <> B And A <> C And A <> D Then
    blue = blue + 1
  End If
  If A = M And A <> B And A <> C And A <> D Then
    blue = blue + 1
  End If
  If B = J And B <> A And B <> C And B <> D Then
    blue = blue + 1
  End If
  If B = L And B <> A And B <> C And B <> D Then
    blue = blue + 1
  End If
  If B = M And B <> A And B <> C And B <> D Then
    blue = blue + 1
  End If
  If C = J And C <> A And C <> B And C <> D Then
    blue = blue + 1
  End If
  If C = K And C <> A And C <> B And C <> D Then
    blue = blue + 1
  End If
  If C = M And C <> A And C <> B And C <> D Then
    blue = blue + 1
  End If
  If D = J And D <> A And D <> B And D <> C Then
    blue = blue + 1
  End If
  If D = K And D <> A And D <> B And D <> C Then
    blue = blue + 1
  End If
  If D = L And D <> A And D <> B And D <> C Then
    blue = blue + 1
  End If
For N = 0 To (red - 1)
Shape1(N + F * 4).FillColor = RGB(255, 0, 0)
Next N
For O = 0 To blue - 1
Shape1(red + (O + F * 4)).FillColor = RGB(0, 0, 255)
Next O
Text2(F) = Text1
Text1.Text = Clear
F = F + 1
Secline: Text1.SetFocus
Lastline: End Sub

Private Sub Command3_Click(Index As Integer)
If Text1 = "请输入一个四位数" Or Text1 = "" Then
Text1 = Command3(Index).Caption
ElseIf Text1 > 0 And Text1 < 1000 Then
Text1 = Text1 * 10 + Command3(Index).Caption
Else
End If
Text1.SetFocus
Screen.ActiveControl.SelStart = Len(Screen.ActiveControl.Text)
If Len(Screen.ActiveControl.Text) = 4 Then
Command2.SetFocus
End If
End Sub

Private Sub Exit_Click()
Command14_Click
End Sub

Private Sub Expert_Click()
Expert.Checked = True: Basic.Checked = False
Option1.Value = False
Option2.Value = True
Command1_Click
Text1.SetFocus
End Sub

Private Sub Form_Load()
Dim A, B, C, D, E
Dim F, G, H, J, K, L, M, N, O
F = 0
Option1.Value = True
Option2.Value = False
Basic.Checked = True
Expert.Checked = False
If Option1.Value = True And Option2.Value = False Then
Firstline: Randomize
A = Int((9 - 2) * Rnd + 1)
B = Int((9 - 1) * Rnd + 0)
C = Int((9 - 1) * Rnd + 0)
D = Int((9 - 1) * Rnd + 0)
If A = B Or A = C Or A = D Or B = C Or B = D Or C = D Then
GoTo Firstline
Else: E = A * 1000 + B * 100 + C * 10 + D
End If
End If
If Option1.Value = False And Option2.Value = True Then
Secondline: Randomize
A = Int((9 - 2) * Rnd + 1)
B = Int((9 - 1) * Rnd + 0)
C = Int((9 - 1) * Rnd + 0)
D = Int((9 - 1) * Rnd + 0)
If A = B And B = C Or A = C And C = D Or A = B And B = D Or B = C And C = D Or A = B And B = C And C = D Or A = C And B = D Or A = D And B = C Or A = B And C = D Then
GoTo Secondline
Else: E = A * 1000 + B * 100 + C * 10 + D
End If
End If
Text1.Text = "请输入一个四位数"
Text3.Text = E
End Sub

Private Sub gamehelp_Click()
Dialog2.Show
End Sub

Private Sub Option1_Click()
Basic_Click
End Sub

Private Sub Option2_Click()
Expert_Click
End Sub

Private Sub Restart_Click()
Dim A, B, C, D, E, i
Unload Answer
Unload Dialog
Unload Dialog1
Unload Dialog2
Unload frmAbout
If Option1.Value = True And Option2.Value = False Then
Firstline: Randomize
A = Int((9 - 2) * Rnd + 1)
B = Int((9 - 1) * Rnd + 0)
C = Int((9 - 1) * Rnd + 0)
D = Int((9 - 1) * Rnd + 0)
If A = B Or A = C Or A = D Or B = C Or B = D Or C = D Then
GoTo Firstline
Else: E = A * 1000 + B * 100 + C * 10 + D
End If
End If
If Option1.Value = False And Option2.Value = True Then
Secondline: Randomize
A = Int((9 - 2) * Rnd + 1)
B = Int((9 - 1) * Rnd + 0)
C = Int((9 - 1) * Rnd + 0)
D = Int((9 - 1) * Rnd + 0)
If A = B And B = C Or A = C And C = D Or A = B And B = D Or B = C And C = D Or A = B And B = C And C = D Or A = C And B = D Or A = D And B = C Or A = B And C = D Then
GoTo Secondline
Else: E = A * 1000 + B * 100 + C * 10 + D
End If
End If
Text1.Text = "请输入一个四位数"
For i = 0 To 47
Shape1(i).FillColor = RGB(255, 255, 255)
Next i
For i = 0 To 11
Text2(i).Text = Clear
Next i
Text3.Text = E
Text1.SetFocus
F = 0
End Sub

Private Sub Result_Click()
Answer.Show
Answer.Label2.Caption = Text3
End Sub

Private Sub Text1_Click()
If Text1.Text = "请输入一个四位数" Then
Text1.Text = Clear
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim Z
If Text1.Text = "请输入一个四位数" Then
Text1.Text = Clear
End If
If KeyAscii = 8 Or KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
Else: KeyAscii = 0
End If
If Len(Text1) = 3 And KeyAscii <> 8 And KeyAscii <> 13 And KeyAscii <> 108 Then
Command2.SetFocus
End If
Lastline: End Sub

Private Sub Text3_GotFocus()
Command1_Click
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -