【VB开源代码栏目提醒】:网学会员鉴于大家对VB开源代码十分关注,论文会员在此为大家搜集整理了“Ex14_1.frm”一文,供大家参考学习
VERSION 5.00
Begin VB.Form Ex14_1
Caption = "Print#语句的使用"
ClientHeight = 2880
ClientLeft = 60
ClientTop = 450
ClientWidth = 4365
LinkTopic = "Form1"
ScaleHeight = 2880
ScaleWidth = 4365
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "第二种方法"
Height = 375
Left = 2280
TabIndex = 2
Top = 2280
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "第一种方法"
Height = 375
Left = 600
TabIndex = 1
Top = 2280
Width = 1335
End
Begin
VB.TextBox Text1
Height = 1815
Left = 360
MultiLine = -1 'True
TabIndex = 0
Top = 240
Width = 3615
End
End
Attribute VB_Name = "Ex14_1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Open "c:\Myfile1.dat" For Output As #1 '打开文件,若没有则创建一个新文件
Print #1, Text1.Text '将文本框中的内容写入c:\Myfile1.dat文件中
Close #1
End Sub
Private Sub Command2_Click()
Open "c:\Myfile2.dat" For Output As #1
'文本框中内容的一半一个字符一个字符地写入文件中
For i = 1 To Len(Text1.Text) / 2
Print #1, Mid(Text1.Text, i, 1);
Next i
Close #1
End Sub