Instruction Manual

3-22
<Toc> <Ind> <3. PC Link Communication >
IM 77J04J11-01E 1st Edition : 2006.08.25-00
Label1.Caption = "[stx]" + strSend + "[etx][cr]"
Label2.Caption = ""
MSComm1.PortOpen = True 'Open port
Timer1.Enabled = True 'Start timer for detecting timeout
Command1.Enabled = False 'Disable the Command button temporarily
fSend = True 'Set sending flag
'Send
MSComm1.Output = Chr(&H2) + strSend + Chr(&H3) + Chr(&HD)
'Send with stx, etx, and cr added
Do 'Loop until sending flag becomes false
If DoEvents() = 0 Then '
End If '
Loop Until fSend = False '
Timer1.Enabled = False 'Stop Timer 1
MSComm1.PortOpen = False 'Close port
Label2.Caption = strReceive 'Display received character string in Label 2
Command1.Enabled = True 'Enable the Command button
End Sub
--------------------------------------------------------------------------------
'At start of program
Private Sub Form_Load()
Form1.Caption = "Communication Sample"
'Set up timer for detecting timeout
Timer1.Enabled = False
Timer1.Interval = 2000
'Regard as being 2 seconds
'Initialize MSComm control
MSComm1.CommPort = 1 'COM1
MSComm1.InputLen = 1 'Size of receiving buffer
MSComm1.InputMode = comInputModeText 'Receiving mode
MSComm1.RThreshold = 1 'MSComm1_OnComm interrupt processing starts
'each time 1 byte is received
MSComm1.Settings = "9600,e,8,1" 'Communication conditions: 9600 bps; Parity,
'even; Data length, 8 bits; Stop bit, 1 bit
'Command button control
Command1.Caption = "Send"