📄 calc.frm
字号:
VERSION 5.00
Begin VB.Form calc
Caption = "计算题"
ClientHeight = 2970
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2970
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Ans
Height = 270
Left = 3360
TabIndex = 20
Top = 360
Width = 855
End
Begin VB.CommandButton Ext
Caption = "退出"
Height = 375
Left = 2880
TabIndex = 19
Top = 1680
Width = 975
End
Begin VB.CommandButton opr
Caption = "/"
Height = 375
Index = 3
Left = 2880
TabIndex = 17
Top = 2400
Width = 375
End
Begin VB.CommandButton opr
Caption = "*"
Height = 375
Index = 2
Left = 2400
TabIndex = 16
Top = 2400
Width = 375
End
Begin VB.CommandButton opr
Caption = "-"
Height = 375
Index = 1
Left = 1920
TabIndex = 15
Top = 2400
Width = 375
End
Begin VB.CommandButton opr
Caption = "+"
Height = 375
Index = 0
Left = 1440
TabIndex = 14
Top = 2400
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 9
Left = 2520
TabIndex = 13
Top = 2040
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 8
Left = 2160
TabIndex = 12
Top = 2040
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 7
Left = 1800
TabIndex = 11
Top = 2040
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 6
Left = 2520
TabIndex = 10
Top = 1680
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 5
Left = 2160
TabIndex = 9
Top = 1680
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 4
Left = 1800
TabIndex = 8
Top = 1680
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 3
Left = 2520
TabIndex = 7
Top = 1320
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 2
Left = 2160
TabIndex = 6
Top = 1320
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 1
Left = 1800
TabIndex = 5
Top = 1320
Width = 375
End
Begin VB.CommandButton n
Height = 375
Index = 0
Left = 2160
TabIndex = 4
Top = 960
Width = 375
End
Begin VB.TextBox num
Alignment = 1 'Right Justify
Height = 270
Index = 1
Left = 1920
Locked = -1 'True
TabIndex = 2
Top = 360
Width = 855
End
Begin VB.TextBox num
Alignment = 1 'Right Justify
Height = 270
Index = 0
Left = 360
Locked = -1 'True
TabIndex = 0
Top = 360
Width = 855
End
Begin VB.CommandButton showscore
Caption = "得分情况"
Height = 375
Left = 840
TabIndex = 18
Top = 1680
Width = 975
End
Begin VB.Label Label2
Caption = "="
Height = 255
Left = 3000
TabIndex = 3
Top = 360
Width = 255
End
Begin VB.Label op
Height = 255
Left = 1440
TabIndex = 1
Top = 360
Width = 255
End
End
Attribute VB_Name = "calc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit '严格变量审查
Public nk As Long, Sum As Long, Trues As Long '共有变量,以供score使用
Private Sub Ans_KeyPress(KeyAscii As Integer)
Dim b As Long
If KeyAscii = 13 Then
Sum = Sum + 1
Select Case op.Caption '选择结构计算结果
Case "+"
b = Val(num(0)) + Val(num(1))
Case "-"
b = Val(num(0)) - Val(num(1))
Case "*"
b = Val(num(0)) * Val(num(1))
Case "/"
b = Val(num(0)) \ Val(num(1))
End Select
If b = Val(Ans) Then Trues = Trues + 1: MsgBox "回答正确" Else MsgBox "回答错误" '判断结果是否正确
num(1).Text = "" '一切改动还原,已进行下次计算
num(0).Text = ""
Ans.Text = ""
op.Caption = ""
KeyAscii = 0
nk = 0
End If
End Sub
Private Sub Ext_Click()
Unload Me
End Sub
Private Sub form_load()
Dim i As Long
For i = 0 To 9 '将十个数字写在按钮数组上
n(i).Caption = i
Next
End Sub
Private Sub n_Click(Index As Integer)
num(nk).Text = num(nk).Text & Index '在纪录的文本框中写数字
End Sub
Private Sub num_gotfocus(Index As Integer)
nk = Index '记录文本框
End Sub
Private Sub opr_Click(Index As Integer) '将运算符写在标签上
op.Caption = opr(Index).Caption
num(1).SetFocus
End Sub
Private Sub showscore_Click()
Score.Show 1, Me '以模态显示窗体,关闭之前不能激活me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -