Sample Visual Basic Code

Using the Demo Application

'

'Event handler for MSComm1 event Private Sub MSComm1_OnComm()

'Get data from Input buffer gstrInputBuffer = MSComm1.Input

'Display received result on the Received text box txtReceived.Text = gstrInputBuffer

End Sub

'Event handler for GetFreq button Private Sub btnGetFreq_Click()

txtCommand.Text = "FREQ?" Call btnSend_Click

End Sub

'Event handler for GetPower button Private Sub btnGetPower_Click()

txtCommand.Text = "PWR?" Call btnSend_Click

End Sub

'Event handler for SetFreq button Private Sub btnSetFreq_Click()

txtCommand.Text = "FREQ " & txtFreq.Text Call btnSend_Click

End Sub

'Event handler for ZeroSensor button Private Sub btnZeroSensor_Click()

txtCommand.Text = "ZERO" Call btnSend_Click

'Sensor will return OK after about 19 Seconds End Sub

'Event handler for Close button Private Sub btnClose_Click()

'

'Make sure we close the com port before we exit the app If MSComm1.PortOpen = True Then

'Stop sensor from making measurements txtCommand.Text = "STOP"

Call btnSend_Click

'

'Wait for half a second after sending START command Delay (0.5)

'

MSComm1.PortOpen = False End If

'Close the app End

End Sub

MA24106A UG

B-3

Page 55
Image 55
Anritsu MA24106A, 0701012 manual Sample Visual Basic Code Using the Demo Application