
46
6 Sample Programs
These programs can be created using Visual Basic 5.0, 6.0 or Visual Basic2013.
Visual Basic is a registered trademark of Microsoft Corporation.
Using Visual Basic 5.0 or 6.0
These sample programs are created with Microsoft Visual Basic 5.0 and 6.0.
The following are used for communication:
For RS-232C/USB communication:
MSComm from Visual Basic Professional
During communications, the terminator setting is supposed to be as follows:
RS-232C/USB:
CR+LF
RS-232C/USB Communications
(Using Microsoft Visual Basic Professional MSComm)
Simple Measurement
Imports measured values 10 times, and saves measurements in a text file.
Private Sub MeasureSubRS()
Dim recvstr As String
'Receiving character string
Dim i As Integer
MSComm1.CommPort = 1
'COM1 (Check a communication port)
MSComm1.Settings = "9600,n,8,1"
'Set a communication port (not required with USB)
MSComm1.PortOpen = True
'Open a port
Open App.Path & "¥data.csv" For Output As #1
'Open a text file for saving
MSComm1.Output = ":FUNC RV" & vbCrLf
'Select (R,X,V,T) measurement function
MSComm1.Output = ":MEAS:VAL 1" & vbCrLf
‘Output only the measurement value
MSComm1.Output = ":TRIG:SOUR IMM" & vbCrLf 'Select an internal triggering
MSComm1.Output = ":INIT:CONT ON" & vbCrLf
'Continuous measurement ON
For i = 1 To 10
MSComm1.Output = ":FETCH?" & vbCrLf
'Send “:FETCH?” to import the most recent measurement
recvstr = ""
'From here on, continue receiving until an LF code occurs
While Right(recvstr, 1) <> Chr(10)
recvstr = r MSComm1.Input
DoEvents
Wend
recvstr = Left(recvstr, Len(recvstr) - 2)
'Delete the terminator (CR+LF)
Print #1, Str(i) & "," & recvstr
'Write to the file
Next
Close #1
MSComm1.PortOpen = False
End Sub
Summary of Contents for BT4560
Page 57: ...54 2 Enter the sample program into the code editor 3 Select Save All from the File menu Click...
Page 60: ...57...
Page 61: ...58...
Page 62: ...59...