Afonsoreis
Member
Hello guys,
Im using a siemens with WINCC in a computer and need to import to tag´s data fom a specific row in a SCV file,
i have a working script but always read the last row
Sub VBFunction_2()
' Read_data_from_file()
Dim fso, f, field, MyZf
FileName = "C:\data.csv"
' Catch errors
On Error Resume Next
' Create file object
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Set f = fspenTextFile(FileName, 1, 0, -2)
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
' Read values till end of file
Do While Not f.AtEndOfStream
MyZf = f.ReadLine
Loop
field = Split(MyZf, ";")
Read_Batchid = field(0)
Read_Temp = field(1)
Read_Presure = field(2)
' Tidy up
fso.Close
Set f = Nothing
Set fso = Nothing
ShowSystemAlarm "Readout of the data was successful!"
End Sub
What a need is to define in a tag a specific row, and import the data in that row.
Thank you all for your help.
Im using a siemens with WINCC in a computer and need to import to tag´s data fom a specific row in a SCV file,
i have a working script but always read the last row
Sub VBFunction_2()
' Read_data_from_file()
Dim fso, f, field, MyZf
FileName = "C:\data.csv"
' Catch errors
On Error Resume Next
' Create file object
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Set f = fspenTextFile(FileName, 1, 0, -2)
If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
' Read values till end of file
Do While Not f.AtEndOfStream
MyZf = f.ReadLine
Loop
field = Split(MyZf, ";")
Read_Batchid = field(0)
Read_Temp = field(1)
Read_Presure = field(2)
' Tidy up
fso.Close
Set f = Nothing
Set fso = Nothing
ShowSystemAlarm "Readout of the data was successful!"
End Sub
What a need is to define in a tag a specific row, and import the data in that row.
Thank you all for your help.