我正在使用 Visual Basic 和 xaml 设计一个应用程序,并且想知道是否有一种“简单”的方法可以将数据读/写到文件中。基本上,我的应用程序在启动时需要记住一些变量(最好存储在数组中)。
问问题
304 次
1 回答
0
来自微软:
Sub OpenExample()
Dim sFirst, sLast, sAddress, sCity, sState, sZip As String
'' CREATE DATA FILE
'' Open file for input.
Open "Datafile.txt" For Output As #1
'' Write data to file.
Write #1, "John", "Doe", "An Address", "A City", "A State", "A Zip"
'' Close File.
Close #1
'' RETRIEVE DATA FROM FILE
'' Open file for input.
Open "Datafile.txt" For Input As #1
'' Loop until the end of file is reached.
Do While Not EOF(1)
'' Read data into variables.
Input #1, sFirst,sLast,sAddress,sCity,sState,sZip
'' Print data to Debug window.
Debug.Print sFirst,sLast,sAddress,sCity,sState,sZip
Loop
'' Close file.
Close #1
End Sub
来自http://support.microsoft.com/kb/209231
使用谷歌搜索词“microsoft vba open for output”找到。
于 2013-08-01T05:18:27.953 回答