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

📄 v6j04-07.frm

📁 简单的VB课程教学课件适合刚刚接触VB学习的学生学习,绝对是这门课程的精化
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "计算机考试"
   ClientHeight    =   4215
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   12
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   4215
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.PictureBox Picture1 
      BackColor       =   &H80000009&
      Height          =   3015
      Left            =   480
      ScaleHeight     =   2955
      ScaleWidth      =   3795
      TabIndex        =   3
      Top             =   840
      Width           =   3855
   End
   Begin VB.CommandButton Command1 
      Caption         =   "计分"
      Height          =   495
      Left            =   2760
      TabIndex        =   2
      Top             =   240
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   1560
      TabIndex        =   1
      Top             =   240
      Width           =   855
   End
   Begin VB.Label Label1 
      Height          =   375
      Left            =   600
      TabIndex        =   0
      Top             =   360
      Width           =   735
   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 Num1 As Integer, Num2 As Integer  '两个操作数
Dim SExp As String
Dim Result As Single                  '计算结果
Dim NOk As Integer, NError As Integer '统计计算正确与错误数


Private Sub Form_Load()
' 通过产生随机数生成表达式
  Dim NOp As Integer, Op As String * 1        '操作符
  Randomize                  '初始化随机数生成器
  Num1 = Int(10 * Rnd + 1)  '产生1-10之间的操作数
  Num2 = Int(10 * Rnd + 1)  '产生1-10之间的操作数
  NOp = Int(4 * Rnd + 1)   '产生1-4之间的操作代码
  Select Case NOp
    Case 1
      Op = "+"
      Result = Num1 + Num2
    Case 2
      Op = "-"
      Result = Num1 - Num2
    Case 3
      Op = "×"
      Result = Num1 * Num2
    Case 4
      Op = "÷"
      Result = Num1 / Num2
   End Select
  SExp = Num1 & Op & Num2 & "="
  Label1 = SExp
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
  If Val(Text1) = Result Then
      Picture1.Print SExp; Text1; Tab(10); "√ "     '计算正确
      NOk = NOk + 1
    Else
      Picture1.Print SExp; Text1; Tab(10); "×"   '计算错误
      NError = NError + 1
    End If
    Text1 = ""                                '下一个表达式生成
    Text1.SetFocus
    Form_Load
  End If
End Sub
Private Sub Command1_Click()
  On Error Resume Next
  Label1 = ""
  Picture1.Print "----------------------------------"
  Picture1.Print "一共计算 " & (NOk + NError) & " 道题";
  Picture1.Print "得分 " & Int(NOk / (NOk + NError) * 100)
End Sub

⌨️ 快捷键说明

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