新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Sub Command1_Click()
Dim intFileNum As Integer
Dim strFN As String
strFN = "manongku.txt"
intFileNum = FreeFile
Open App.Path & "/" & strFN For Output As #intFileNum
Print #intFileNum, "码农库MaNongKu.com"
Close #intFileNum
MsgBox "已经保存到文件:" & strFN, vbInformation, "完成"
End Sub
其中,经过TypeName (FreeFile)测试,FreeFile的类型是Integer。