
3-6
4 Programming Example
The following examples are written in Visual Basic.
Example 1) OPEN the Shield Box
Private Sub Form_Load()
MSComm1.Rthreshold = 1
MSComm1.CommPort = 1 ' select COM1
MSComm1.Settings = "9600, N, 8, 1"
` Baud Rate(9600 bps), Parity Bit(None), Data Bit(8 bit), Stop Bit(1 bit)
MSComm1.PortOpen = True ' Open Com Port.
MSComm1.Output = "OPEN" + Chr(13) ` send command .
MSComm1.PortOpen = False ` Close Com Port.
End Sub
Example 2) Check "OK" is received in input Buffer
Private Sub MSComm1_OnComm()
` Triggers when TX or RX event occurs
If MSComm1.CommEvent = 2 Then ` event in input Buffer
Text1.Text = MSComm1.Input ' read the input string and check later if it is “OK”
End If
End Sub
3-3 PC Control Using Communication Program