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

📄 form1002.frm

📁 VB实验教程源码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "添加记录"
   ClientHeight    =   3375
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3375
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      Caption         =   "结束"
      Height          =   375
      Left            =   3360
      TabIndex        =   12
      Top             =   2160
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "添加记录"
      Enabled         =   0   'False
      Height          =   375
      Left            =   3360
      TabIndex        =   11
      Top             =   1320
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "打开文件"
      Height          =   375
      Left            =   3360
      TabIndex        =   10
      Top             =   600
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   4
      Left            =   1680
      TabIndex        =   9
      Top             =   2640
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   3
      Left            =   1680
      TabIndex        =   7
      Top             =   2040
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   2
      Left            =   1680
      TabIndex        =   5
      Top             =   1440
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   1
      Left            =   1680
      TabIndex        =   3
      Top             =   840
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Index           =   0
      Left            =   1680
      TabIndex        =   1
      Top             =   240
      Width           =   1095
   End
   Begin VB.Label Label5 
      Caption         =   "英语"
      Height          =   375
      Left            =   480
      TabIndex        =   8
      Top             =   2640
      Width           =   1095
   End
   Begin VB.Label Label4 
      Caption         =   "数学"
      Height          =   375
      Left            =   480
      TabIndex        =   6
      Top             =   2040
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   "语文"
      Height          =   255
      Left            =   480
      TabIndex        =   4
      Top             =   1560
      Width           =   1095
   End
   Begin VB.Label Label2 
      Caption         =   "姓名"
      Height          =   375
      Left            =   480
      TabIndex        =   2
      Top             =   960
      Width           =   1095
   End
   Begin VB.Label Label1 
      Caption         =   "学号"
      Height          =   375
      Left            =   480
      TabIndex        =   0
      Top             =   240
      Width           =   1095
   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 Score As ScoreType
Dim RecL As Long, RecN As Long
Dim FileN As Integer
    
Private Sub Command1_Click()
'单击打开文件按钮
    FileN = FreeFile
    RecL = Len(Score)
    '用随机访问方式打开
    Open "c:\考试成绩" For Random As FileN Len = RecL
    Command2.Enabled = True
End Sub

Private Sub Command2_Click()
'单击添加记录按钮
    Dim i As Integer
    '找到最后记录号
    RecN = LOF(FileN) / RecL + 1
    For i = 0 To 4
        If Text1(i) = "" Then
            MsgBox "无输入数据", "输入数据"
            Exit Sub
        End If
    Next i
    With Score
        .学号 = Text1(0).Text
        .姓名 = Text1(1).Text
        .语文 = Val(Text1(2).Text)
        .数学 = Val(Text1(3).Text)
        .英语 = Val(Text1(4).Text)
    End With
    Put #FileN, RecN, Score
    For i = 0 To 4
        Text1(i) = ""
    Next i
    Command1.Enabled = False
End Sub

Private Sub Command3_Click()
'单击结束按钮
    Close #FileN
    End
End Sub

Private Sub Form_Load()
    Dim Data As Single
    Open "c:\考试成绩" For Binary As #1
    Put #1, 40, "2003010106"
    
End Sub

⌨️ 快捷键说明

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