?? frmmath.frm
字號:
VERSION 5.00
Begin VB.Form frmMath
Caption = "Math"
ClientHeight = 6030
ClientLeft = 60
ClientTop = 345
ClientWidth = 9240
LinkTopic = "Form1"
ScaleHeight = 6030
ScaleWidth = 9240
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "&Exit"
Height = 615
Left = 7080
TabIndex = 5
Top = 5040
Width = 1455
End
Begin VB.CheckBox chkDisplay
Caption = "&Display summary information"
Height = 375
Left = 5760
TabIndex = 4
Top = 2520
Width = 2895
End
Begin VB.Frame frmInfo
Height = 1455
Left = 5760
TabIndex = 3
Top = 3000
Visible = 0 'False
Width = 2775
Begin VB.Label Label2
Caption = "Incorrect:"
Height = 255
Left = 1560
TabIndex = 17
Top = 240
Width = 855
End
Begin VB.Label Label1
Caption = "Correct:"
Height = 255
Left = 120
TabIndex = 16
Top = 240
Width = 855
End
Begin VB.Label lblIncorrect
Height = 495
Left = 1560
TabIndex = 15
Top = 720
Width = 855
End
Begin VB.Label lblCorrect
Height = 495
Left = 120
TabIndex = 14
Top = 720
Width = 855
End
End
Begin VB.Frame frmOperations
Caption = "Operations"
Height = 1935
Left = 2640
TabIndex = 2
Top = 2520
Width = 2055
Begin VB.OptionButton optSub
Caption = "&Subtraction"
Height = 375
Left = 240
TabIndex = 13
Top = 960
Width = 1575
End
Begin VB.OptionButton optAdd
Caption = "&Addition"
Height = 375
Left = 240
TabIndex = 12
Top = 480
Width = 1575
End
End
Begin VB.Frame frmLevel
Caption = "Levels"
Height = 1935
Left = 360
TabIndex = 1
Top = 2520
Width = 2055
Begin VB.OptionButton optLevel2
Caption = "Level&2 (10-100)"
Height = 375
Left = 120
TabIndex = 11
Top = 960
Width = 1815
End
Begin VB.OptionButton optLevel1
Caption = "Level&1 (1-10)"
Height = 375
Left = 120
TabIndex = 10
Top = 480
Width = 1815
End
End
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 1575
Left = 240
TabIndex = 0
Top = 360
Width = 8655
Begin VB.CommandButton cmdVerify
Caption = "&Verify Answer"
Height = 495
Left = 6480
TabIndex = 9
Top = 600
Width = 1575
End
Begin VB.TextBox txtAnswer
Height = 495
Left = 3840
TabIndex = 8
Top = 600
Width = 855
End
Begin VB.Image imgIcon
Height = 495
Left = 5040
Top = 600
Width = 855
End
Begin VB.Image imgEqual
Height = 480
Left = 3120
Picture = "frmMath.frx":0000
Top = 600
Width = 480
End
Begin VB.Image imgOperator
Height = 495
Left = 1200
Top = 600
Width = 735
End
Begin VB.Label lblNum2
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋體"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 525
Left = 2040
TabIndex = 7
Top = 600
Width = 840
End
Begin VB.Label lblNum1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "宋體"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 495
Left = 240
TabIndex = 6
Top = 600
Width = 780
End
End
Begin VB.Image imgMinus
Height = 480
Left = 1800
Picture = "frmMath.frx":0442
Top = 5040
Visible = 0 'False
Width = 480
End
Begin VB.Image imgPlus
Height = 480
Left = 1080
Picture = "frmMath.frx":0884
Top = 5040
Visible = 0 'False
Width = 480
End
Begin VB.Image imgHappy
Height = 480
Left = 360
Picture = "frmMath.frx":0CC6
Top = 5040
Visible = 0 'False
Width = 480
End
End
Attribute VB_Name = "frmMath"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim intNum1 As Integer, intNum2 As Integer, intTemp As Integer
Private Sub chkDisplay_Click()
If chkDisplay.Value = vbChecked Then
frmInfo.Visible = True
Else
frmInfo.Visible = False
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Public Sub RandomNumbers()
Randomize
If optLevel1.Value = True Then
intNum1 = Int((10 - 1 + 1) * Rnd + 1)
intNum2 = Int((10 - 1 + 1) * Rnd + 1)
Else
intNum1 = Int((100 - 10 + 1) * Rnd + 10)
intNum2 = Int((100 - 10 + 1) * Rnd + 10)
End If
If optSub.Value = True And intNum2 > intNum1 Then
intTemp = intNum1
intNum1 = intNum2
intNum2 = intTemp
End If
lblNum1.Caption = intNum1
lblNum2.Caption = intNum2
End Sub
Private Sub cmdVerify_Click()
Const conBtns As String = vbOKOnly + vbInformation + vbDefaultButton1 + vbApplicationModal
Dim intUserAnswer As Integer, intCorrectAnswer As Integer, intRetVal As Integer
Static intNumCorrect As Integer, intNumIncorrect As Integer
intUserAnswer = Val(txtAnswer.Text)
If optAdd.Value = True Then
intCorrectAnswer = intNum1 + intNum2
Else
intCorrectAnswer = intNum1 - intNum2
End If
Select Case intUserAnswer
Case Is = intCorrectAnswer
imgIcon.Picture = imgHappy.Picture
intNumCorrect = intNumCorrect + 1
txtAnswer.Text = ""
Call RandomNumbers
Case Else
imgIcon.Picture = LoadPicture()
intNumIncorrect = intNumIncorrect + 1
intRetVal = MsgBox("Try again.", conBtns, "Math Application")
txtAnswer.SelStart = 0
txtAnswer.SelLength = Len(txtAnswer.Text)
End Select
txtAnswer.SetFocus
lblCorrect.Caption = intNumCorrect
lblIncorrect.Caption = intNumIncorrect
End Sub
Private Sub Form_Load()
frmMath.Top = (Screen.Height - frmMath.Height) / 2
frmMath.Left = (Screen.Width - frmMath.Width) / 2
optLevel1.Value = True
optAdd.Value = True
Randomize
Call RandomNumbers
End Sub
Private Sub optAdd_Click()
imgOperator.Picture = imgPlus.Picture
txtAnswer.Text = ""
Call RandomNumbers
End Sub
Private Sub optLevel1_Click()
Call RandomNumbers
End Sub
Private Sub optLevel2_Click()
Call RandomNumbers
End Sub
Private Sub optSub_Click()
imgOperator.Picture = imgMinus.Picture
txtAnswer.Text = ""
Call RandomNumbers
txtAnswer.SetFocus
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -