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

📄 form1.frm

📁 猜数字
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "猜数字!"
   ClientHeight    =   2220
   ClientLeft      =   150
   ClientTop       =   720
   ClientWidth     =   3660
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2220
   ScaleWidth      =   3660
   StartUpPosition =   3  '窗口缺省
   Begin VB.ListBox List1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF8080&
      Height          =   2220
      Left            =   1730
      TabIndex        =   7
      TabStop         =   0   'False
      Top             =   0
      Width           =   1935
   End
   Begin VB.Frame Frame2 
      Caption         =   "最接近成功的一次"
      Height          =   615
      Left            =   0
      TabIndex        =   5
      Top             =   1560
      Width           =   1695
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "8"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   200
         TabIndex        =   12
         Top             =   240
         Visible         =   0   'False
         Width           =   180
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "8"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   560
         TabIndex        =   11
         Top             =   240
         Visible         =   0   'False
         Width           =   180
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "8"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   945
         TabIndex        =   10
         Top             =   240
         Visible         =   0   'False
         Width           =   180
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "8"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   300
         Left            =   1300
         TabIndex        =   9
         Top             =   240
         Visible         =   0   'False
         Width           =   180
      End
      Begin VB.Label Label1 
         Height          =   375
         Left            =   240
         TabIndex        =   8
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "猜猜猜"
      Height          =   1335
      Left            =   0
      TabIndex        =   6
      Top             =   120
      Width           =   1695
      Begin VB.CommandButton Command1 
         Caption         =   "我猜"
         Default         =   -1  'True
         Enabled         =   0   'False
         Height          =   300
         Left            =   240
         TabIndex        =   4
         Top             =   960
         Width           =   1095
      End
      Begin VB.TextBox Text4 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15.75
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   405
         Left            =   1095
         TabIndex        =   3
         Top             =   360
         Width           =   285
      End
      Begin VB.TextBox Text3 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15.75
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   405
         Left            =   810
         TabIndex        =   2
         Top             =   360
         Width           =   285
      End
      Begin VB.TextBox Text2 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15.75
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   405
         Left            =   525
         TabIndex        =   1
         Top             =   360
         Width           =   285
      End
      Begin VB.TextBox Text1 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15.75
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   405
         Left            =   240
         TabIndex        =   0
         Top             =   360
         Width           =   285
      End
   End
   Begin VB.Label Label7 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "OK!"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   285
      Left            =   1800
      TabIndex        =   14
      Top             =   360
      Width           =   510
   End
   Begin VB.Label Label6 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "16"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   285
      Left            =   1800
      TabIndex        =   13
      Top             =   0
      Width           =   345
   End
   Begin VB.Image Image1 
      Height          =   2235
      Left            =   1778
      Picture         =   "Form1.frx":08CA
      Top             =   0
      Width           =   1830
   End
   Begin VB.Menu mnfile 
      Caption         =   "文件"
      Begin VB.Menu mnnew 
         Caption         =   "新游戏"
      End
      Begin VB.Menu mnrule 
         Caption         =   "规则"
      End
      Begin VB.Menu mnexit 
         Caption         =   "退出"
      End
   End
   Begin VB.Menu mnkjg 
      Caption         =   "看结果"
   End
   Begin VB.Menu mnabout 
      Caption         =   "关于"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private a As Integer
Private b As Integer
Private c As Integer
Private d As Integer
Private jishu As Integer
Private ba As Integer
Private bb As Integer



Function getabcd(a As Integer, b As Integer, c As Integer, d As Integer)
Randomize
100
a = Int(10 * Rnd)
If a = 0 Then
GoTo 100
End If
110
b = Int(10 * Rnd)
If b = a Or b = 0 Then
   GoTo 110
End If
120
c = Int(10 * Rnd)
If c = a Or c = b Or c = 0 Then
   GoTo 120
End If
130
d = Int(10 * Rnd)
If d = a Or d = b Or d = c Or d = 0 Then
GoTo 130
End If
End Function
Private Sub Command1_GotFocus()
If Text1.Text = Text2.Text Or Text1.Text = Text2.Text Or Text1.Text = Text3.Text Or Text1.Text = Text4.Text Or Text2.Text = Text3.Text Or Text2.Text = Text4.Text Or Text3.Text = Text4.Text Then
       Call MsgBox(" 输入有错!重来!", 0, "NO,NO,NO!")
       Text1.Text = ""
       Text2.Text = ""
       Text3.Text = ""
       Text1.SetFocus
       Command1.Enabled = False
End If
End Sub

Private Sub Form_Load()
getabcd a, b, c, d
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub

Private Sub mnabout_Click()
Form2.Show 1
End Sub

Private Sub mnexit_Click()
Unload Me
End Sub

Private Sub mnkjg_Click()
Label1.Visible = False
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label2.Caption = b
Label3.Caption = c
Label4.Caption = d
Label5.Caption = a

End Sub

Private Sub mnnew_Click()
List1.Visible = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Label1.Visible = True
Label1.Caption = ""
Command1.Enabled = False
Text1.SetFocus
List1.Clear
getabcd a, b, c, d
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
jishu = 0
ba = 0
bb = 0
Frame2.Caption = "最接近成功的一次"
End Sub

Private Sub mnrule_Click()
Form3.Show
End Sub

Private Sub Text1_GotFocus()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Command1.Enabled = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 49 Or KeyAscii > 57 Then
   KeyAscii = 0
Else
Text2.SetFocus
End If
End Sub

Private Sub Text2_GotFocus()
Text2.Text = ""
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii < 49 Or KeyAscii > 57 Then
   KeyAscii = 0
Else
Text3.SetFocus
End If
End Sub

Private Sub Text3_GotFocus()
Text3.Text = ""
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii < 49 Or KeyAscii > 57 Then
   KeyAscii = 0
Else
Text4.SetFocus
End If
End Sub

Private Sub Text4_GotFocus()
Text4.Text = ""
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii < 49 Or KeyAscii > 57 Then
   KeyAscii = 0
Else
   If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
      Text1.SetFocus
      Text1.Text = ""
      Text2.Text = ""
      Text3.Text = ""
      Text4.Text = ""
   Else
      Command1.Enabled = True
      Command1.SetFocus
   End If
End If
End Sub

Private Sub Command1_Click()
Dim a1 As Integer
Dim b1 As Integer
Dim e As String
Dim f As String
Dim g As String
Dim h As String
Dim s As String
jishu = jishu + 1
If Text1.Text = a Then
   a1 = a1 + 1
   Else
     If Text1.Text = b Or Text1.Text = c Or Text1.Text = d Then
        b1 = b1 + 1
     End If
End If
If Text2.Text = b Then
   a1 = a1 + 1
   Else
     If Text2.Text = a Or Text2.Text = c Or Text2.Text = d Then
        b1 = b1 + 1
     End If
End If
If Text3.Text = c Then
   a1 = a1 + 1
   Else
     If Text3.Text = b Or Text3.Text = a Or Text3.Text = d Then
        b1 = b1 + 1
     End If
End If
If Text4.Text = d Then
   a1 = a1 + 1
   Else
     If Text4.Text = b Or Text4.Text = c Or Text4.Text = a Then
        b1 = b1 + 1
     End If
End If


If jishu < 10 Then
   s = " " & jishu & " " & Text1.Text & Text2.Text & Text3.Text & Text4.Text & " " & a1 & "A" & b1 & "B"
Else
   s = jishu & " " & Text1.Text & Text2.Text & Text3.Text & Text4.Text & " " & a1 & "A" & b1 & "B"
End If
List1.AddItem s, 0
If a1 > ba Then
   Label1.Caption = s
   ba = a1
   bb = b1
Else
   If a1 = ba And b1 >= bb Then
      Label1.Caption = s
      ba = a1
      bb = b1
   End If
End If
If a1 = 4 Then
Frame2.Caption = "******成了******"
   List1.Visible = False
   Label1.Visible = False
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label2.Caption = b
Label3.Caption = c
Label4.Caption = d
Label5.Caption = a
Label6.Caption = jishu
End If

Text1.SetFocus



End Sub

⌨️ 快捷键说明

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