📄 form1004.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 Fso As New FileSystemObject
Dim TextFile As TextStream
Private Sub Command1_Click()
'单击创建文件按钮
Set Fso = CreateObject("Scripting.FileSystemObject")
'创建新文件
Set TextFile = Fso.CreateTextFile("c:\考试成绩.txt", True)
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
'单击写入记录按钮
Dim LineString As String
Dim i As Integer
For i = 0 To 4
If Text1(i) = "" Then
MsgBox "数据未输完", "输入数据"
Exit Sub
End If
Next i
LineString = "学号 " & Text1(0).Text
LineString = LineString & " 姓名" & Text1(1).Text
LineString = LineString & " 语文" & Val(Text1(2).Text)
LineString = LineString & " 数学" & Val(Text1(3).Text)
LineString = LineString & " 英语" & Val(Text1(4).Text)
TextFile.WriteLine LineString
Command1.Enabled = False
For i = 0 To 4
Text1(i) = ""
Next i
End Sub
Private Sub Command3_Click()
'单击结束按钮
TextFile.Close
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -