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

📄 frmgrade.frm

📁 是《VISUAL BASIC编程》(英文原版 提高版) 的8个习题 已完成 供大家参考
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmGrade 
   Caption         =   "Form1"
   ClientHeight    =   5490
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7155
   LinkTopic       =   "Form1"
   ScaleHeight     =   5490
   ScaleWidth      =   7155
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   495
      Left            =   5040
      TabIndex        =   16
      Top             =   4200
      Width           =   1455
   End
   Begin VB.CommandButton cmdPrint 
      Caption         =   "&Print"
      Height          =   495
      Left            =   2880
      TabIndex        =   15
      Top             =   4200
      Width           =   1335
   End
   Begin VB.CommandButton cmdDisplay 
      Caption         =   "&Display Grade"
      Enabled         =   0   'False
      Height          =   540
      Left            =   720
      TabIndex        =   14
      Top             =   4200
      Width           =   1335
   End
   Begin VB.TextBox txtScore 
      Enabled         =   0   'False
      Height          =   495
      Index           =   4
      Left            =   5160
      TabIndex        =   11
      Text            =   "0"
      Top             =   2520
      Width           =   1215
   End
   Begin VB.TextBox txtScore 
      Enabled         =   0   'False
      Height          =   495
      Index           =   3
      Left            =   5160
      TabIndex        =   10
      Text            =   "0"
      Top             =   1800
      Width           =   1215
   End
   Begin VB.TextBox txtScore 
      Enabled         =   0   'False
      Height          =   495
      Index           =   2
      Left            =   1920
      TabIndex        =   9
      Text            =   "0"
      Top             =   3240
      Width           =   1215
   End
   Begin VB.TextBox txtScore 
      Enabled         =   0   'False
      Height          =   495
      Index           =   1
      Left            =   1920
      TabIndex        =   8
      Text            =   "0"
      Top             =   2520
      Width           =   1215
   End
   Begin VB.TextBox txtScore 
      Enabled         =   0   'False
      Height          =   495
      Index           =   0
      Left            =   1920
      TabIndex        =   7
      Text            =   "0"
      Top             =   1800
      Width           =   1215
   End
   Begin VB.CheckBox chkDone 
      Caption         =   "&Final"
      Height          =   495
      Index           =   4
      Left            =   3600
      TabIndex        =   6
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CheckBox chkDone 
      Caption         =   "&Midtrem"
      Height          =   495
      Index           =   3
      Left            =   3600
      TabIndex        =   5
      Top             =   1800
      Width           =   1215
   End
   Begin VB.CheckBox chkDone 
      Caption         =   "Project &3"
      Height          =   495
      Index           =   2
      Left            =   480
      TabIndex        =   4
      Top             =   3240
      Width           =   1215
   End
   Begin VB.CheckBox chkDone 
      Caption         =   "Project &2"
      Height          =   495
      Index           =   1
      Left            =   480
      TabIndex        =   3
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CheckBox chkDone 
      Caption         =   "Project &1"
      Height          =   495
      Index           =   0
      Left            =   480
      TabIndex        =   2
      Top             =   1800
      Width           =   1215
   End
   Begin VB.TextBox txtName 
      Height          =   495
      Left            =   1320
      TabIndex        =   1
      Top             =   240
      Width           =   2415
   End
   Begin VB.Label lblGrade 
      BackColor       =   &H8000000E&
      BorderStyle     =   1  'Fixed Single
      Height          =   495
      Left            =   5160
      TabIndex        =   18
      Top             =   3240
      Width           =   1215
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "Grade:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   3840
      TabIndex        =   17
      Top             =   3360
      Width           =   720
   End
   Begin VB.Label Label3 
      Caption         =   "50 points"
      Height          =   255
      Left            =   5280
      TabIndex        =   13
      Top             =   1320
      Width           =   975
   End
   Begin VB.Label Label2 
      Caption         =   "10 points"
      Height          =   255
      Left            =   2160
      TabIndex        =   12
      Top             =   1320
      Width           =   855
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Name:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   600
      TabIndex        =   0
      Top             =   360
      Width           =   525
   End
End
Attribute VB_Name = "frmGrade"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Private Sub chkDone_Click(Index As Integer)
    Dim intCount As Integer, strChecked As String
    If chkDone(Index).Value = vbChecked Then
        cmdDisplay.Enabled = True
        txtScore(Index).Enabled = True
        txtScore(Index).SetFocus
    Else
        txtScore(Index).Text = 0
        txtScore(Index).Enabled = False
        strChecked = "N"
        Do While intCount <= 4 And strChecked = "N"
            If chkDone(intCount).Value = vbChecked Then
                strChecked = "Y"
            End If
            intCount = intCount + 1
        Loop
        If strChecked = "N" Then
            cmdDisplay.Enabled = False
        End If
    End If
End Sub

Private Sub cmdDisplay_Click()
    Dim intEarned As Integer, intPossible As Integer
    Dim sngRatio As Single, intCount As Integer
    For intCount = 0 To 4
        If chkDone(intCount).Value = vbChecked Then
            intEarned = intEarned + Val(txtScore(intCount).Text)
            Select Case intCount
                Case 0 To 2
                    intPossible = intPossible + 10
                Case Else
                    intPossible = intPossible + 50
                End Select
        End If
     Next intCount
     sngRatio = intEarned / intPossible
     Select Case sngRatio
        Case Is >= 0.9
            lblGrade.Caption = "A"
        Case Is >= 0.8
            lblGrade.Caption = "B"
        Case Is >= 0.7
            lblGrade.Caption = "C"
        Case Is >= 0.6
            lblGrade.Caption = "D"
        Case Else
            lblGrade.Caption = "F"
    End Select
        
End Sub

Private Sub cmdExit_Click()
    Unload frmGrade
End Sub

Private Sub cmdPrint_Click()
    PrintForm
End Sub

Private Sub Form_Load()
    frmGrade.Top = (Screen.Height - frmGrade.Height) / 2
    frmGrade.Left = (Screen.Width - frmGrade.Width) / 2
    
End Sub


Private Sub Form_Unload(Cancel As Integer)
    Const conBtons As Integer = vbYesNo + vbDefaultButton1 + vbApplicationModal
    Dim intUserResponse As Integer
    intUserResponse = MsgBox("Do you want to exit?", conBtons, "Grade Application")
    If intUserResponse = vbNo Then
        Cancel = 1
    End If
End Sub


Private Sub txtName_Change()
    lblGrade.Caption = ""
End Sub

Private Sub txtScore_GotFocus(Index As Integer)
    txtScore(Index).SelStart = 0
    txtScore(Index).SelLength = Len(txtScore(Index).Text)
    
End Sub

⌨️ 快捷键说明

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