Thanks for the The Tuto ! verry helpful. a question: it is possible to add a VB fuction to the project without adding the wincc like in your Exemple. is that possible to make a short tuto for it ? thanks!
with this script I can directly create a csv file on the pc without the hmi panel, right? where to insert the vb file since the script folder is not present
'***************** Write data to CSV File************************* Sub VBFunction_1() ' Write_data_to_file Dim fso, f, ts 'Catch errors On Error Resume Next Datetime = Now() 'Create object Set fso = CreateObject("Scripting.FileSystemObject") If Err.Number 0 Then ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description Err.Clear Exit Sub End If ' If no file exists, create a new one If Not fso.FileExists(FileName) Then fso.CreateTextFile FileName End If Set f = fso.GetFile(FileName) If Err.Number 0 Then ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description Err.Clear Exit Sub End If Set ts = f.OpenAsTextStream(8, -2) ' mode "8" to append to file If Err.Number 0 Then ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description Err.Clear Exit Sub End If ' Write new set of values into file ts.WriteLine(Material & ";" & Pressure & ";" & Temperature & ";" & Datetime) 'Tidy up ts.Close Set f = Nothing ShowSystemAlarm "Storage of the data was successful!" End Sub ' ********Read data from CSV File****************************** Sub VBFunction_4() ' Read_data_from_file() Dim fso, f, field, MyZf ' 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 = fso.OpenTextFile(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, ";") MaterialFromFile = field(0) PressureFromFile = field(1) TemperatureFromFile = field(2) ' Tidy up fso.Close Set f = Nothing Set fso = Nothing ShowSystemAlarm "Readout of the data was successful!" End Sub '**********************************************************
@@automationonline It's possible search 25/10/2022 value in column ex :"A"(date), and show values B and C in tags. same like this vlookup. A | B | C | 10/10/2022 | 102.0 | 99.5 | 25/10/2022 | 102.0 | 99.5 |*** 28/10/2022 | 102.0 | 99.5 |
Terrific!!!! Very good explanation works very well 😃😃😃
Thanks for the The Tuto ! verry helpful.
a question: it is possible to add a VB fuction to the project without adding the wincc like in your Exemple.
is that possible to make a short tuto for it ?
thanks!
How can i Read row by row and save in the list of variables for use in the main?
Very usefull! Bravo!
Is it possible to create a new file when you change batch?
with this script I can directly create a csv file on the pc without the hmi panel, right?
where to insert the vb file
since the script folder is not present
at 9:38, the thing I dont understand why is you set your file name is data3.csv, but it clearly is excel file. How can be?
how many variables can be set in the trend ?
Hello, thank you for your sharing. How can I save data in different file month by month?
Really Good Question, I'm waiting for the Answer
can you give the program ?
(a copy paste in the comments is enough)
'***************** Write data to CSV File*************************
Sub VBFunction_1()
' Write_data_to_file
Dim fso, f, ts
'Catch errors
On Error Resume Next
Datetime = Now()
'Create object
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
' If no file exists, create a new one
If Not fso.FileExists(FileName) Then
fso.CreateTextFile FileName
End If
Set f = fso.GetFile(FileName)
If Err.Number 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
Set ts = f.OpenAsTextStream(8, -2)
' mode "8" to append to file
If Err.Number 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If
' Write new set of values into file
ts.WriteLine(Material & ";" & Pressure & ";" & Temperature & ";" & Datetime)
'Tidy up
ts.Close
Set f = Nothing
ShowSystemAlarm "Storage of the data was successful!"
End Sub
' ********Read data from CSV File******************************
Sub VBFunction_4()
' Read_data_from_file()
Dim fso, f, field, MyZf
' 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 = fso.OpenTextFile(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, ";")
MaterialFromFile = field(0)
PressureFromFile = field(1)
TemperatureFromFile = field(2)
' Tidy up
fso.Close
Set f = Nothing
Set fso = Nothing
ShowSystemAlarm "Readout of the data was successful!"
End Sub
'**********************************************************
@@automationonline It's possible search 25/10/2022 value in column ex :"A"(date), and show values B and C in tags. same like this vlookup.
A | B | C |
10/10/2022 | 102.0 | 99.5 |
25/10/2022 | 102.0 | 99.5 |***
28/10/2022 | 102.0 | 99.5 |
Cool! Thanks a lot!
sir how to read in between line data's
Thanks alot
it does't work with real HMI (tp 900 comfort)
hello . Can I have the source code please?