Hi
I'm trying to make a VB program for interacting with a Nortel PBX through a serial port.
First What I've got to see the PBX port status, For This send a CrLf to the PBX and wait for the response, If the port is free I will receive "OVL111" + CrLf. If I receive OVL111 I can send a user and a password to the PBX.
I also want to show the receive data on a RechTextBox, below is the program for detecting the "OVL111" word:
Dim Buffer As String
Dim Varix As String
Private Sub Command1_Click()
MSComm1.Output = vbCrLf
End Sub
Private Sub Form_Load()
MSComm1.InputLen = 0 ' Read All
MSComm1.RThreshold = 1
MSComm1.CommPort = 2 'COM 2
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Dim pos As Integer
Select Case MSComm1.CommEvent
Case comEvReceive
Buffer = MSComm1.Input
'Show received data from the PBX on RichtextBox
'RichTextBox1.SelStart = Len(RichTextBox1.Text)
'RichTextBox1.SelText = Buffer
Varix = Varix + Buffer
'If Arrive CrLF then look for OVL111
If Right(Varix, 2) = vbCrLf Then
pos = InStr(Varix, "OVL111")
If pos > 0 Then 'If pos > 0 then I found OVL111
Print "Found OVL111" 'Print the data colected
Print Varix
Varix = ""
End If
End If
End Select
End Sub
If I show the received data on the ReichTextBox using:
RichTextBox1.SelStart = Len(RichTextBox1.Text)
RichTextBox1.SelText = Buffer
I have to click several times Command1_Click() for detecting OVL111.
If I don't show the receive data in the RichTextBox the program found OVL111 at once
Any ideas?
I'm trying to make a VB program for interacting with a Nortel PBX through a serial port.
First What I've got to see the PBX port status, For This send a CrLf to the PBX and wait for the response, If the port is free I will receive "OVL111" + CrLf. If I receive OVL111 I can send a user and a password to the PBX.
I also want to show the receive data on a RechTextBox, below is the program for detecting the "OVL111" word:
Dim Buffer As String
Dim Varix As String
Private Sub Command1_Click()
MSComm1.Output = vbCrLf
End Sub
Private Sub Form_Load()
MSComm1.InputLen = 0 ' Read All
MSComm1.RThreshold = 1
MSComm1.CommPort = 2 'COM 2
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Dim pos As Integer
Select Case MSComm1.CommEvent
Case comEvReceive
Buffer = MSComm1.Input
'Show received data from the PBX on RichtextBox
'RichTextBox1.SelStart = Len(RichTextBox1.Text)
'RichTextBox1.SelText = Buffer
Varix = Varix + Buffer
'If Arrive CrLF then look for OVL111
If Right(Varix, 2) = vbCrLf Then
pos = InStr(Varix, "OVL111")
If pos > 0 Then 'If pos > 0 then I found OVL111
Print "Found OVL111" 'Print the data colected
Print Varix
Varix = ""
End If
End If
End Select
End Sub
If I show the received data on the ReichTextBox using:
RichTextBox1.SelStart = Len(RichTextBox1.Text)
RichTextBox1.SelText = Buffer
I have to click several times Command1_Click() for detecting OVL111.
If I don't show the receive data in the RichTextBox the program found OVL111 at once
Any ideas?