新建一个标准Exe文件
添加两个命令按钮,一个通用对话框控件
Private Sub Command1_Click()
Dim FileName As String
With CommonDialog1
.Filter = "Text File(*.txt)|*.txt"
.FilterIndex = 1
.DialogTitle = "Save File"
.ShowSave
FileName = .FileName
If Len(FileName) = 0 Then Exit Sub
End With
Dim hFile As Integer
hFile = FreeFile
Open FileName For Output As #hFile
Print #hFile, Text1.Text
Close #hFile
End SubPrivate Sub Command2_Click()
Dim FileName As String
With CommonDialog1
.Filter = "Text File(*.txt)|*.txt"
.FilterIndex = 1
.DialogTitle = "Open File"
.ShowOpen
FileName = .FileName
If Len(FileName) = 0 Then Exit Sub
End With
Dim hFile As Integer
hFile = FreeFile
Open FileName For Binary As #hFile
Text1.Text = Input(LOF(hFile), hFile)
Close #hFile
End SubPrivate Sub Form_Load()
Command1.Caption = "Save File"
Command2.Caption = "Load File"
Text1.Text = ""
End Sub
添加两个命令按钮,一个通用对话框控件
Private Sub Command1_Click()
Dim FileName As String
With CommonDialog1
.Filter = "Text File(*.txt)|*.txt"
.FilterIndex = 1
.DialogTitle = "Save File"
.ShowSave
FileName = .FileName
If Len(FileName) = 0 Then Exit Sub
End With
Dim hFile As Integer
hFile = FreeFile
Open FileName For Output As #hFile
Print #hFile, Text1.Text
Close #hFile
End SubPrivate Sub Command2_Click()
Dim FileName As String
With CommonDialog1
.Filter = "Text File(*.txt)|*.txt"
.FilterIndex = 1
.DialogTitle = "Open File"
.ShowOpen
FileName = .FileName
If Len(FileName) = 0 Then Exit Sub
End With
Dim hFile As Integer
hFile = FreeFile
Open FileName For Binary As #hFile
Text1.Text = Input(LOF(hFile), hFile)
Close #hFile
End SubPrivate Sub Form_Load()
Command1.Caption = "Save File"
Command2.Caption = "Load File"
Text1.Text = ""
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货