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

📄 例10.11.frm

📁 一本学习Visual Basic编程的好书
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1 
   BackColor       =   &H80000000&
   Caption         =   "简单算术运算练习"
   ClientHeight    =   3105
   ClientLeft      =   165
   ClientTop       =   855
   ClientWidth     =   4905
   LinkTopic       =   "Form1"
   ScaleHeight     =   3105
   ScaleWidth      =   4905
   StartUpPosition =   3  '窗口缺省
   Begin MSComctlLib.StatusBar StatusBar1 
      Align           =   2  'Align Bottom
      Height          =   315
      Left            =   0
      TabIndex        =   7
      Top             =   2790
      Width           =   4905
      _ExtentX        =   8652
      _ExtentY        =   556
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   3
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.ToolTipText     =   "提示信息"
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Style           =   1
            Enabled         =   0   'False
            TextSave        =   "CAPS"
            Object.ToolTipText     =   "大小写状态"
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Style           =   5
            TextSave        =   "22:04"
            Object.ToolTipText     =   "时间"
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   525
      Left            =   0
      TabIndex        =   6
      Top             =   0
      Width           =   4905
      _ExtentX        =   8652
      _ExtentY        =   926
      ButtonWidth     =   820
      ButtonHeight    =   767
      Appearance      =   1
      ImageList       =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   3
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "加法"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "减法"
            ImageIndex      =   2
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "乘法"
            ImageIndex      =   3
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   4275
      Top             =   525
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   10
      ImageHeight     =   10
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   3
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例10.11.frx":0000
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例10.11.frx":005C
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例10.11.frx":0ACA
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.TextBox Text1 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   390
      Left            =   1125
      TabIndex        =   5
      Top             =   1125
      Width           =   1665
   End
   Begin VB.CommandButton Command2 
      Caption         =   "答题"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2775
      TabIndex        =   3
      Top             =   1950
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "命题"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1200
      TabIndex        =   1
      Top             =   1950
      Width           =   975
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   2925
      TabIndex        =   0
      Text            =   " "
      Top             =   1125
      Width           =   990
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Caption         =   "填写答案"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Left            =   3000
      TabIndex        =   2
      Top             =   750
      Width           =   915
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      Caption         =   "运算题"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   1650
      TabIndex        =   4
      Top             =   750
      Width           =   765
   End
   Begin VB.Menu mnu10 
      Caption         =   "位数"
      Begin VB.Menu mnu11 
         Caption         =   "一位数"
      End
      Begin VB.Menu mnu12 
         Caption         =   "两位数"
      End
      Begin VB.Menu mnu13 
         Caption         =   "三位数"
      End
   End
   Begin VB.Menu mnu20 
      Caption         =   "运算"
      Begin VB.Menu mnu21 
         Caption         =   "加法"
      End
      Begin VB.Menu mnu22 
         Caption         =   "减法"
      End
      Begin VB.Menu mnu23 
         Caption         =   "乘法"
      End
   End
   Begin VB.Menu mnu30 
      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          '显式声明变量
Dim sel1 As Integer, sel2 As String
Dim r1 As Long
Private Sub Form_Load()
    sel1 = 0             '位数标记
    sel2 = ""            '运算标记
    StatusBar1.Panels.Item(1) = "正在运行中"
    Randomize
End Sub
Private Sub mnu11_click()
    sel1 = 1             '设置位数标记
End Sub
Private Sub mnu12_click()
    sel1 = 10
End Sub
Private Sub mnu13_click()
    sel1 = 100
End Sub
Private Sub mnu21_click()
    sel2 = "+"           '设置运算标记
End Sub
Private Sub mnu22_click()
    sel2 = "-"
End Sub
Private Sub mnu23_click()
    sel2 = "*"
End Sub
Private Sub command1_click()  '"命题"按钮单击事件
    Dim a As Long, b As Long
    If sel1 = 0 Or sel2 = "" Then
         MsgBox "先选择运算数的位数和运算类型"
         Exit Sub
    End If
                    '随机生成指定位数的操作数
    a = sel1 + Int(9 * sel1 * Rnd)
    b = sel1 + Int(9 * sel1 * Rnd)
                    '组成算式
    Text1.Text = Str(a) + sel2 + Str(b) + "="
    Select Case sel2     '求运算结果r1
        Case "+"
            r1 = a + b
        Case "-"
            r1 = a - b
        Case "*"
            r1 = a * b
    End Select
    Text2.Text = ""
    Text2.SetFocus
End Sub
Private Sub command2_click()  '"答题"按钮单击事件
    Dim r2 As Long
    If Text2.Text = "" Then
         MsgBox "请输入答案"
         Exit Sub
    End If
    r2 = Val(Text2.Text)    '读取用户的答案
    If r1 = r2 Then         '判断答案
        MsgBox "回答正确"
    Else
        MsgBox "回答错误"
    End If
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    Select Case Button.Index
        Case 1
             sel2 = "+"
        Case 2
             sel2 = "-"
        Case 3
             sel2 = "*"
    End Select
End Sub

Private Sub mnu30_click()   '"结束"按钮单击事件
    End
End Sub



⌨️ 快捷键说明

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