VB值保存

来源:百度知道 编辑:UC知道 时间:2024/05/23 10:21:09
将text2.text 的值保存到文件里 最好不是txt扩散名的 然后下次开启的时候在次提取

'保存文件
Dim H As Long
H = FreeFile
Open "C:\My1.aaa" For Output As #H '打开文件
Print #H, Text2.Text '写文件
Close #H '关闭文件

'读文件
Dim nStr As String, Str1 As String, H As Long
H = FreeFile
Open "C:\My1.aaa" For Input As #H
Do
If EOF(H) Then Exit Do
Input #H, Str1 '从文件中读出一行字符串
nStr = nStr & Str1 & vbCrLf
Loop
Close #H
Text2.Text = nStr

天极网上有详细的VB操作文件的教程,可以供你参考:
http://www.yesky.com/zhuanti/395/1788895.shtml