保存文件的步骤为:
关闭流,特别是写入流
关闭并保存文件
示例代码如下:
Imports System.Windows.FormsImports System.IO
Imports System.Text
Sub SaveFileDemo()
'打开文件。如果文件不存在则创建新的文件
Dim myFile As New IO.FileStream("d:\data.txt", _
FileMode.OpenOrCreate, _
FileAccess.Write)
'在文件末尾添加一行
Dim tw As New StreamWriter(myFile)
myFile.Seek(0, SeekOrigin.End)
tw.WriteLine("白刃格斗英雄连英模部队方队亮相阅兵")
'关闭流
tw.Close()
'关闭文件并保存文件
myFile.Close()
End Sub
1.使用文件来记录,下次运行时读取.2.使用数据库,可以考虑单机数据库或网络数据库 3.如果数据量小,使用注册表.或者可以通过程序来保存:
set fs=createobject("scripting.filesystemobject")'创建文件 *** 作对象
if fs.fileexists("C:\a.txt") then'如果C盘A.txt存在,那么读取其内容
set txt=fs.opentextfile("C:\a.txt",forreading,true)
set txtn=txt.readall
else'
set txtf=fs.createtextfile("c:\a.txt",true)'创建C盘下的a.txt
do'无限循环
wscript.sleep 1000'延时一秒
txtf.write a.text'写入文本框中内容
loop'循环结束
end if'判断结束
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)