实验成功的WINCC读取TXT文件代码--VBS
时间:2026-01-16
时间:2026-01-16
Dim fso
Dim txtfile
Dim a
'a=HMIRuntime.Tags("FileName").Read
Set fso = CreateObject("scripting.filesystemobject")
If fso.FileExists("E:\test\Export\UserArchiveControl\12345678FAIL.txt") Then
'MsgBox "文件存在"
'If fso.FileExists("D:\\Export&Import\\"&CStr(a)&".txt") Then
Set txtfile = fso.OpenTextFile("E:\test\Export\UserArchiveControl\12345678FAIL.txt")
MsgBox "开始读取" HMIRuntime.Tags("Var_1").Write txtfile.ReadLine HMIRuntime.Tags("Var_2").Write txtfile.ReadLine HMIRuntime.Tags("Var_3").Write txtfile.ReadLine HMIRuntime.Tags("Var_4").Write txtfile.ReadLine HMIRuntime.Tags("Var_5").Write txtfile.ReadLine HMIRuntime.Tags("Var_6").Write txtfile.ReadLine HMIRuntime.Tags("Var_7").Write txtfile.ReadLine HMIRuntime.Tags("Var_8").Write txtfile.ReadLine HMIRuntime.Tags("Var_9").Write txtfile.ReadLine HMIRuntime.Tags("Var_10").Write txtfile.ReadLine HMIRuntime.Tags("Var_11").Write txtfile.ReadLine HMIRuntime.Tags("Var_12").Write txtfile.ReadLine HMIRuntime.Tags("Var_13").Write txtfile.ReadLine HMIRuntime.Tags("Var_14").Write txtfile.ReadLine HMIRuntime.Tags("Var_15").Write txtfile.ReadLine HMIRuntime.Tags("Var_16").Write txtfile.ReadLine HMIRuntime.Tags("Var_17").Write txtfile.ReadLine HMIRuntime.Tags("Var_18").Write txtfile.ReadLine HMIRuntime.Tags("Var_19").Write txtfile.ReadLine HMIRuntime.Tags("Var_20").Write txtfile.ReadLine MsgBox "导入数据成功/Import Successful" txtfile.Close Else MsgBox "文件不存在/File is not existing" End If
下一篇:练习题二——扭转