Omega Model CYD211 User’s Manual
4-8 Remote
Operation
Table 4-3. Visual Basic Serial Interface Program
Public gSend As Boolean
'Global used for Send button state
Private Sub cmdSend_Click()
'Routine to handle Send button press
gSend = True
'Set Flag to True
End Sub
Private Sub Form_Load()
'Main code section
Dim strReturn As String
'Used to return response
Dim strHold As String
'Temporary character space
Dim Term As String
'Terminators
Dim ZeroCount As Integer
'Counter used for Timing out
Dim strCommand As String
'Data string sent to instrument
frmSerial.Show
'Show main window
Term = Chr(13) & Chr(10)
'Terminators are <CR><LF>
ZeroCount = 0
'Initialize counter
strReturn = ""
'Clear return string
strHold = ""
'Clear holding string
If frmSerial.MSComm1.PortOpen = True Then '
Close serial port to change settings
frmSerial.MSComm1.PortOpen = False
End If
frmSerial.MSComm1.CommPort = 1
'Example of Comm 1
frmSerial.MSComm1.Settings = "9600,o,7,1" 'Baud,Parity,Data,Stop
frmSerial.MSComm1.InputLen = 1
'Read one character at a time
frmSerial.MSComm1.PortOpen = True
'Open port
Do
Do
'Wait loop
DoEvents
'Give up processor to other events
Loop Until gSend = True
'Loop until Send button pressed
gSend = False
'Set Flag as false
strCommand = frmSerial.txtCommand.Text
'Get Command
strReturn = ""
'Clear response display
strCommand = UCase(strCommand)
'Set all characters to upper case
If strCommand = "EXIT" Then
'Get out on EXIT
End
End If
Program continues on the next page...