`
q_wong
  • 浏览: 105759 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

VBA读写文件

阅读更多

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
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics