Const fileName = "D:\autoSaveParam.txt"

Const Forreading=1
Const ForWriting=2
Const Forappending=8
Dim hP100,hP103,hP105
Dim  Fso ,tf

'the file exists or not
Set Fso = CreateObject("Scripting.FileSystemObject")
If Fso.fileexists(fileName)Then
       'read from file
       Set tf =Fso.opentextfile(fileName,Forreading)
       Do While tf.atendofstream<>True 
            strLine =   tf.ReadLine        
       Loop 

Else 'file not exist
       'create a file and save P paramters into the file
       Set tf=  fso.OpenTextFile(fileName, ForWriting, True)
       tf.writeLine "P105 = 105"
          
End If 
tf.close 
Set Fso =  Nothing

其中,创建一个新的文件,并向文件写入文本也可以用以下方式:

 'create file and write 
  Dim fso,tf
  Set fso =  CreateObject("Scripting.FileSystemObject")
  Set tf = fso.CreateTextFile(strFileName, True) 'True-代表可以被下次写入覆盖

  tf.WriteLine("AABBCC")
  tf.close

 

参考:https://blog.csdn.net/hc19881010/article/details/5963818?locationNum=15&fps=1

          https://www.docin.com/p-1613338.html

相关文章:

  • 2021-07-25
  • 2022-01-29
  • 2021-05-30
  • 2021-06-19
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-11
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案