| Shell, Append, Kill |
| |
| |
| Const Dateiname = "C:\Messwerte.dat" | Da die Datei mit Notepad geöffnet wird, muss ein konkreter |
| Pfad benannt werden. |
| Private Sub cmdProtokoll_Click() | |
| Dim Rückgabewert As Long | Datei mit Notepad öffnen (ohne Pfad geht’s nicht). |
| Rückgabewert = Shell("Notepad " & Dateiname, vbNormalFocus) |
| End Sub | |
| |
| Private Sub cmdProtokollLöschen_Click() | |
| Dim Antwort As Long | |
| Antwort = MsgBox(Prompt:="Protokolldatei löschen?", _ | |
| Buttons:=vbQuestion + vbYesNo, Title:="Ja oder nein?") | |
| If Antwort = vbYes Then Kill Dateiname | Datei löschen. |
| End Sub | |
| |
| Private Sub cmdStart_Click() | Messdaten-Aufzeichnung starten. |
| Static Modus As Boolean | |
| Modus = Not Modus | |
| If Modus Then | |
| If IsNumeric(txtIntervall.Text) = False Then |
| tmrZeit.Interval = 1000 |
| Else |
| tmrZeit.Interval = txtIntervall.Text |
| End If |
| tmrZeit.Enabled = True |
| cmdStart.Caption = "&Anhalten" |
| Else |
| tmrZeit.Enabled = False |
| cmdStart.Caption = "&Weiter" |
| End If | |
| End Sub | |
| |
| Private Sub Form_Load() | Programmstart. |
| Dim DateiNr As Integer | |
| DateiNr = FreeFile | |
| tmrZeit.Enabled = False | |
| txtIntervall.Text = "1000" | |
| Open Dateiname For Append As DateiNr | TextDatei wird für sequentiellen Append-Zugriff geöffnet. |
| Write #DateiNr, Now | Bei jedem Öffnen wird Datum und Uhrzeit in die Datei |
| Close | geschrieben. |
| End Sub | |
| |
| Private Sub lstMesswerte_Click() | |
| lstMesswerte.Clear | |
| End Sub | |
| |
| Private Sub tmrZeit_Timer() | Ablauf des Timers. |
| Dim Zahl1 As Double, Zahl2 As Double | |
| Dim DateiNr As Integer | |
| DateiNr = FreeFile | |
| Zahl1 = Rnd * 1000 | |
| Zahl2 = Rnd * 1000 | |
| lstMesswerte.AddItem "Wert1:=" & Format(Zahl1, ".00") & ":" & "Wert2:=" & Format(Zahl2, ".00") |
| Open Dateiname For Append As DateiNr | TextDatei wird für sequentiellen Append-Zugriff geöffnet. |
| Write #DateiNr, CStr(Zahl1) & ":"; | |
| Write #DateiNr, CStr(Zahl2) | |
| Close | |
| End Sub | |
| |