给你个简单的列子 参考吧Private filenum As IntegerPrivate Sub Command1_Click() For x = 1 To 10 '随机输入10个数 Savetofile filenum, CStr(Rnd * 100) Next End SubPrivate Sub Savetofile(filenum As Integer, str As String) Print #filenum, str End SubPrivate Sub Form_Load() filenum = FreeFile Open "e:\1.txt" For Output As #filenum End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Close #x End Sub
put
print
write
writefile
createfile
For x = 1 To 10 '随机输入10个数
Savetofile filenum, CStr(Rnd * 100)
Next
End SubPrivate Sub Savetofile(filenum As Integer, str As String)
Print #filenum, str
End SubPrivate Sub Form_Load()
filenum = FreeFile
Open "e:\1.txt" For Output As #filenum
End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Close #x
End Sub
改成
Close #filenum