ITeye博客

VBA读写文件

q_wong · 2010-04-27 09:41 · Default · 编程语言 · C · VBA · C++ · C# · Markdown

VBA读写文件

Private Sub CommandButton1_Click()
Dim txt As String
Dim myString As String
Dim myNumber

txt = "C:\IDP-CI.Path"

Open txt For Output As #1 '...写文件
strData = "welcome,"
Print #1, strData, 123

Close #1


If Dir(txt) = "" Then
MsgBox "error"
Else
Open txt For Input As #2
Do While Not EOF(2)    ' 循环至文件尾。
    Input #2, myString, myNumber   ' 将数据读入两个变量。
Loop
Close #2
MsgBox myString
End If
End Sub

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。