打印本文打印本文 关闭窗口关闭窗口

如何读取TXT文件内容?

作者:金字塔 来源:cxh99.com 发布时间:2015年08月23日
  • 咨询内容: 我们知道,在后台,可以用debugfile将变量输出到文件,反过来,要将TXT文件中的一个数值,如何读取到金字塔后台的变量中?深度请教!

     

  • 金字塔客服:

    3.1版已经增加了INI文本文件的读写函数,你可以直接使用这个来操作了

     

    参考

    http://www.weistock.com/bbs/dispbbs.asp?boardid=2&Id=59406

    [此贴子已经被作者于2014/1/18 14:10:47编辑过]

     

  • 用户回复: Sub WriteTxt() Set WSHShell = CreateObject("WScript.Shell") DesktopPath = WSHShell.SpecialFolders("Desktop") xFile = DesktopPath & "\config.txt" MyTxt = Application.AppPath & " 文件创建时间 " & Now() Set fso = CreateObject("scripting.FileSystemObject")    '绑定fso对象 Set MyFile = fso.CreateTextFile(xFile, True) MyFile.WriteLine (MyTxt) MyFile.Close Set MyFile = Nothing Set fso = NothingEnd SubSub ReadTxt() Set WSHShell = CreateObject("WScript.Shell") DesktopPath = WSHShell.SpecialFolders("Desktop") xFile = DesktopPath & "\config.txt" Set fso = CreateObject("scripting.FileSystemObject")    '绑定fso对象 Set MyFile = fso.openTextFile(xFile, 1, True)       '用.open方法打开文件 Do Until MyFile.AtEndOfStream    strLine = MyFile.ReadLine    application.MsgOut strLine Loop MyFile.Close Set MyFile = Nothing Set fso = NothingEnd Sub

     

  • 网友回复: 请问楼上这个是在自定义函数里面实现吗?
打印本文打印本文 关闭窗口关闭窗口