Chapter 2
Chapter 2 installation Guideline 2
-17
Program Source Codes:
OPEN Command Button:
Private Sub Command1_Click()
' Buffer to hold input string
Dim Instring As String
' Use COM1.
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True
End Sub
SEND Command Button:
Private Sub Command2_Click()
' Send Get AI command to ADAM-4011 Module at address 01H.
MSComm1.Output = "#01" & Chr$(13)
' Wait for data to come back to the serial port.
Do
DoEvents
Buffer$ = Buffer$ & MSComm1.Input
Loop Until InStr(Buffer$, vbCr)
' Read the response till the carriage return character.
Text1.Text = Buffer$
' Display the reading.
End Sub
CLOSE Command Button
Private Sub Command3_Click()
' Close the serial port.
MSComm1.PortOpen = False
End Sub