Private Sub Command1_Click()
[b]On Error GoTo MyError[/b]
If opt_Cus_log1.Value = True Or ans = 6 Then
If opt_txt.Value = True Then
[b]CommonDialog1.CancelError = True[/b]
CommonDialog1.DialogTitle = "Save Log File"
CommonDialog1.Flags = cdlOFNHideReadOnly
CommonDialog1.Filter = "Text Files (*.txt)|*.txt|"
CommonDialog1.FilterIndex = 1
CommonDialog1.InitDir = "C:\Program Files\FYP System\Log File\" & user_reg.txt_username
CommonDialog1.ShowSave
If CommonDialog1.FileName = "" Then
Timer1.Enabled = False
Exit Sub
Else
show_dir = CommonDialog1.FileName
End If
End If
com2 = 1
Timer1.Enabled = True
Shape1.BackColor = vbGreen
lbl_Status.Caption = "Scanning..."
lbl_Status.ForeColor = vbGreen
cmd_scan.Caption = "Scan OFF"
start_datetime = Now
Else
com2 = 0
Timer1.Enabled = False
Shape1.BackColor = vbRed
lbl_Status.Caption = "Stop"
lbl_Status.ForeColor = vbRed
cmd_scan.Caption = "Scan ON"
end_datetime = Now
If com2 = 0 Then
'******************************************************************************
'TXT Format
'******************************************************************************
If opt_txt.Value = True Then
Open show_dir For Append As #1
Print #1, "************************************************************************"
Print #1, "Digital Curemeter Data Acqusition and Display System"
Print #1, '""
Print #1, "Experimenter..............", username
Print #1, "Sampling Frequency........", TxtRate & " miliseconds"
Print #1, "Start time................", start_datetime
Print #1, "End time..................", end_datetime
Print #1, "Total number of Data......", lbl_listcount.Caption
Print #1, "Tag Name..................", Text2.Text
Print #1, "Units.....................", Text7.Text
Print #1, "************************************************************************"
Print #1, '""
Print #1, "COLLECTION OF DATA (Analog Input of 8 Channel)"
Print #1, ""
Print #1, " No CHN 1 CHN 2 CHN 3 CHN 4 CHN 5 CHN 6 CHN 7 CHN 8"
Print #1, "------------------------------------------------------------------------"
For a = 0 To List1(0).ListCount - 1
Print #1, Format(a + 1, "00000");
For b = 0 To 7
Print #1, Right$(Space(8) & List1(b).List(a), 8);
Next b
Print #1,
Next
Close #1
End If
End If
End If
Exit Sub
[b]MyError:
If Err.Number <> cdlerror Then
MsgBox Err.Number & " - " & Err.Description
End If[/b]
End Sub