Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. Sub Write_data_to_file()
  2. Dim fso, f, ts, folder, path, zawartosc_pliku
  3. 'Dim strDate
  4. 'Dim strTime
  5. 'Dim dtmValue
  6. 'Dim objFSO
  7. 'Dim fo
  8.  
  9. 'strDate = "\Storage Card USB\" & Month(dtmValue) & "_" & Day(dtmValue) & "_"&Year(dtmValue)
  10. 'strTime = strDate & "\" & Hour(dtmValue) & "-" & Minute(dtmValue) & "-" & Second(dtmValue) & ".csv"
  11. FileName = "D:\text.txt"
  12. FileNex = "D:\text1.txt"
  13. 'folder = "D:\"
  14. 'path = folder & "11.txt"
  15.  
  16.  
  17.  
  18.  
  19. 'Set objFSO = CreateObject("FileCtl.Filesystem")
  20. 'Set fo= CreateObject("FileCtl.File")
  21. 'If objFSO.FolderExists (strDate) Then
  22.  '    If Not objFSO.FileExists (strTime) Then
  23.  '          objFSO.CreateTextFile(strTime)
  24.  '    End If
  25. 'Else
  26.    '  objFSO.CreateFolder (strDate)
  27.    '  objFSO.CreateTextFile (strTime)
  28. 'End If
  29. 'zawartosc_pliku = SmartTags("sila) & ",0,0,0,0,0,0,0,"
  30.  
  31. 'Catch errors -- Fehler abfangen
  32. On Error Resume Next
  33. 'Create object -- Objekt erstellen
  34. Set fso = CreateObject("Scripting.FileSystemObject")
  35. If Err.Number <> 0 Then
  36. ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
  37. Err.Clear
  38. Exit Sub
  39. End If
  40.  
  41. ' If no file exists, create a new one -– Datei erstellen, wenn keine vorhanden
  42. If Not fso.FileExists(FileName) Then
  43. fso.CreateTextFile FileName
  44. End If
  45.  
  46. 'folder = "C:\Program Dates\Data_OUT\"
  47. 'path = folder & "11.txt"
  48.  
  49.  
  50. Set f = fso.GetFile(FileName)
  51. If Err.Number <> 0 Then
  52. ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
  53. Err.Clear
  54. Exit Sub
  55. End If
  56.  
  57. Set ts = f.OpenAsTextStream(8, -2)
  58. ' mode "8" to append to file
  59. If Err.Number <> 0 Then
  60. ShowSystemAlarm "Error #" & CStr(Err.Number) & " " & Err.Description
  61. Err.Clear
  62. Exit Sub
  63. End If
  64.  
  65. ' Write new set of values into file -- Neue Werte in die Datei schreiben'Please replace all sequences which are enclosed with '_' by your own code.
  66. 'Do While Bools
  67. 'statements
  68. 'ts.WriteLine("")
  69. 'ts.WriteLine("")
  70. 'ts.WriteLine("START")
  71. 'ts.WriteLine("Rozpoczęcie rejestracyji.")
  72. 'ts.WriteLine("Użytkownik:")
  73. 'ts.WriteLine(user)
  74. 'ts.WriteLine("Czas rozpoczęcia")
  75. 'ts.WriteLine(Czas_poczatkowy)
  76. 'dopisac czas jak zadziala
  77. 'ts.WriteLine("Czas;Przesuniecie;Pomiar Siła")
  78. 'Do
  79. 'If Zapis_do_pliku = True Then
  80. 'ts.WriteLine(Czas_trwania_prasowania & ";"& Pozycja_przesuniecie & ";" & Pomiar_cisnienie) '
  81. 'Odkomentować na obiekcie
  82. 'End If
  83. 'Loop Until Przycisk_Start1 = True
  84.  
  85. 'ts.WriteLine("Czas zakończenia")
  86. 'ts.WriteLine(Czas_zakonczenia)
  87. 'ts.WriteLine("Zakończenie rejestracji.")
  88. 'Loop
  89. 'Tidy up -- Aufraeumen
  90. ts.Close
  91. Set f = Nothing
  92. Set ts = Nothing
  93. Set fso = Nothing
  94. ShowSystemAlarm "Storage of the data was successful!"
  95.  
  96. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement