Trích dẫn Gửi bởi hiennguyen Xem bài viết
anh Hưng cái project trong link này giờ mình muốn nó xuất dữ liệu ra 1 file trong thư mục của mình muốn phải làm sao??,e thử đổi đoạn script thành
If bExtension = 0 Then
'path = "\flash\textfile.txt"
path = "\C:\Documents and Settings\TIA-Portal\Desktop\textfile.txt"
Else
'path = "\flash\textfile.csv"
path = "\C:\Documents and Settings\TIA-Portal\Desktop\textfile.csv"
End If
mà không được,và đây là nguyên mẫu đoạn code để save dữ liệu ra text file dạng .csv hay .txt ,ghi ra đây để cho anh em tiện xem,hoặc vào link bên trên down cả project về
Dim f, path

If bExtension = 0 Then
'path = "\flash\textfile.txt"
path = "\Storage Card2\textfile.txt"
Else
'path = "\flash\textfile.csv"
path = "\Storage Card2\textfile.csv"
End If

'Error Routine - Fehlerroutine
On Error Resume Next

'Create object - Objekt erstellen
Set f = CreateObject("FileCtl.File")

If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If

'Open the textfile - Öffnen der Textdatei
f.open path , 2

If Err.Number <> 0 Then
ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
Err.Clear
Exit Sub
End If

'Write values into the textfile
f.LinePrint("material; " & szMaterial & ";")
f.LinePrint("pressure; " & nPressure & "; mbar;")
f.LinePrint("temperature; " & nTemperature & "; °C;")

'Close file - Datei schließen
f.Close
Set f = Nothing

ShowSystemAlarm "Storage of the data was successful!"
Em sữa 1 chỗ không thì nó không có chạy đâu,trong file còn có 2 cái đoạn cript nữa,em vô đó sữa tiếp.