fso.OpenTextFile 中filename参数,为何使用变量无效

Set str_temp1=HMIRuntime.Tags("Time")
   str_temp1.Read
   str_time=str_temp1.Value

filename="d:\"&str_time&".txt"      这个变量如何设置?猜想是这里出问题了
 Set fso = CreateObject("scripting.FileSystemObject")
 Set f = fso.OpenTextFile(filename, ForWriting, True)
f.WriteLine "Hello world!"
f.WriteLine "Hello world!"
f.close

最佳答案

filename="d:\"&str_time&".txt" 不对。
应该使用strcat函数,将所有字符串拼接在一起,然后再传递给下面的函数。

提问者对于答案的评价:
谢谢

原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc250982.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2018年12月3日
下一篇 2018年12月3日

相关推荐