pexam5_7.frm
来自「深圳大学的vb上机与教学的课件」· FRM 代码 · 共 299 行
FRM
299 行
VERSION 5.00
Begin VB.Form Form1
Caption = "四则运算"
ClientHeight = 2355
ClientLeft = 60
ClientTop = 345
ClientWidth = 4575
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 2355
ScaleWidth = 4575
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "退出"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2880
TabIndex = 10
Top = 1560
Width = 615
End
Begin VB.CommandButton Command3
Caption = "判断"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1995
TabIndex = 9
Top = 1560
Width = 615
End
Begin VB.CommandButton Command2
Caption = "计算"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1125
TabIndex = 8
Top = 1560
Width = 615
End
Begin VB.CommandButton Command1
Caption = "出题"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 7
Top = 1560
Width = 615
End
Begin VB.TextBox Text4
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2640
TabIndex = 6
Top = 720
Width = 1575
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1440
TabIndex = 3
Top = 720
Width = 615
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 2
Top = 720
Width = 615
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3120
MaxLength = 1
TabIndex = 1
Top = 120
Width = 1095
End
Begin VB.Label Label4
Alignment = 2 'Center
AutoSize = -1 'True
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 435
Left = 3960
TabIndex = 11
Top = 1560
Width = 255
End
Begin VB.Label Label3
Alignment = 2 'Center
AutoSize = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "="
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2160
TabIndex = 5
Top = 720
Width = 315
End
Begin VB.Label Label2
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 960
TabIndex = 4
Top = 720
Width = 375
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "请输入运算类型(+、-、*、/)"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 120
TabIndex = 0
Top = 240
Width = 3090
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Randomize
Text2.Text = Int(Rnd * 1000 + 1)
Text3.Text = Int(Rnd * 1000 + 1)
Text4.Text = ""
End Sub
Private Sub Command2_Click()
If Label2.Caption = "+" Then
Text4.Text = Val(Text2.Text) + Val(Text3.Text)
ElseIf Label2.Caption = "-" Then
Text4.Text = Val(Text2.Text) - Val(Text3.Text)
ElseIf Label2.Caption = "*" Then
Text4.Text = Val(Text2.Text) * Val(Text3.Text)
ElseIf Label2.Caption = "/" Then
Text4.Text = Val(Text2.Text) / Val(Text3.Text)
Else
a = MsgBox("运算类型错,请重输", , "警告")
Text1.SetFocus
End If
End Sub
Private Sub Command3_Click()
Select Case Label2.Caption
Case "+"
If Text4.Text = Val(Text3.Text) + Val(Text2.Text) Then
Label4.Caption = "正确"
Else
Label4.Caption = "错误"
End If
Case "-"
If Text4.Text = Val(Text2.Text) - Val(Text3.Text) Then
Label4.Caption = "正确"
Else
Label4.Caption = "错误"
End If
Case "*"
If Text4.Text = Val(Text3.Text) * Val(Text2.Text) Then
Label4.Caption = "正确"
Else
Label4.Caption = "错误"
End If
Case "/"
' If Text4.Text = Val(Text2.Text) / Val(Text3.Text) Then
If Abs(Val(Text4.Text) - Val(Text2.Text) / Val(Text3.Text)) < 0.000001 Then
Label4.Caption = "正确"
Else
Label4.Caption = "错误"
End If
Case Else
a = MsgBox("运算类型错,请重输", , "警告")
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Select
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Text1_Change()
Label2.Caption = Text1.Text
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?