C
cmdolcet69
I tried to create a multiple COM port which i was success in doing
for just one com port. What seems to be going on is this If I detect
multiple COM port by my activeCOM arraylist then I loop thought the
for loop. In the Ocp.Open it goes to another method and opens the com
port.... When it tries to open the second com port it goes to the
Ocp2.open and open that com2 port... Or its suppose to...Its seems as
if the COM port just open the last created com port....
Can anyone help its urgent?
Public Sub Indicator_COM()
Dim intloop As Integer
For _COMPortIndex = 0 To ActiveCOM.Count - 1
If _COMPortIndex = 0 Then
intCommPort = ActiveCOM(_COMPortIndex)
'IndicatorCOMPort
intBaud = 57600
intData = 8
bytParity = RS232.DataParity.Parity_None
bytStop = RS232.DataStopBit.StopBit_1
oCP.Open(intCommPort, intBaud, intData, bytParity,
bytStop, 4096)
tmrRead.Enabled = True
MenuItem2.Enabled = False
MenuItem3.Enabled = True
ToolBar1.Buttons(0).Enabled = False
ToolBar1.Buttons(1).Enabled = True
TextBox1.Enabled = True
TextBox2.Enabled = True
btnClear.Enabled = True
Me.btnSendTable.Enabled = True
_IndicatorCOM = intCommPort
ElseIf _COMPortIndex = 1 Then
intCommPort2 = ActiveCOM(_COMPortIndex)
'IndicatorCOMPort2
intBaud = 57600
intData = 8
bytParity = RS232.DataParity.Parity_None
bytStop = RS232.DataStopBit.StopBit_1
oCP2.Open(intCommPort2, intBaud, intData, bytParity,
bytStop, 4096)
tmrRead.Enabled = True
MenuItem2.Enabled = False
MenuItem3.Enabled = True
ToolBar1.Buttons(0).Enabled = False
ToolBar1.Buttons(1).Enabled = True
TextBox1.Enabled = True
TextBox2.Enabled = True
btnClear.Enabled = True
Me.btnSendTable.Enabled = True
_IndicatorCOM2 = intCommPort2
End If
'_COMPortIndex += 1
Next
End Sub
Public Overloads Sub Open(ByVal Port As Integer, _
ByVal BaudRate As Integer, ByVal DataBit As Integer, _
ByVal Parity As DataParity, ByVal StopBit As DataStopBit, _
ByVal BufferSize As Integer)
Me.Port = Port
Me.BaudRate = BaudRate
Me.DataBit = DataBit
Me.Parity = Parity
Me.StopBit = StopBit
Me.BufferSize = BufferSize
Open()
End Sub
Public Overloads Sub Open(ByVal Port2 As Integer, _
ByVal BaudRate As Integer, ByVal DataBit As Integer, _
ByVal Parity As DataParity, ByVal StopBit As DataStopBit, _
ByVal BufferSize As Integer)
Me.Port = Port2
Me.BaudRate = BaudRate
Me.DataBit = DataBit
Me.Parity = Parity
Me.StopBit = StopBit
Me.BufferSize = BufferSize
Open()
End Sub
for just one com port. What seems to be going on is this If I detect
multiple COM port by my activeCOM arraylist then I loop thought the
for loop. In the Ocp.Open it goes to another method and opens the com
port.... When it tries to open the second com port it goes to the
Ocp2.open and open that com2 port... Or its suppose to...Its seems as
if the COM port just open the last created com port....
Can anyone help its urgent?
Public Sub Indicator_COM()
Dim intloop As Integer
For _COMPortIndex = 0 To ActiveCOM.Count - 1
If _COMPortIndex = 0 Then
intCommPort = ActiveCOM(_COMPortIndex)
'IndicatorCOMPort
intBaud = 57600
intData = 8
bytParity = RS232.DataParity.Parity_None
bytStop = RS232.DataStopBit.StopBit_1
oCP.Open(intCommPort, intBaud, intData, bytParity,
bytStop, 4096)
tmrRead.Enabled = True
MenuItem2.Enabled = False
MenuItem3.Enabled = True
ToolBar1.Buttons(0).Enabled = False
ToolBar1.Buttons(1).Enabled = True
TextBox1.Enabled = True
TextBox2.Enabled = True
btnClear.Enabled = True
Me.btnSendTable.Enabled = True
_IndicatorCOM = intCommPort
ElseIf _COMPortIndex = 1 Then
intCommPort2 = ActiveCOM(_COMPortIndex)
'IndicatorCOMPort2
intBaud = 57600
intData = 8
bytParity = RS232.DataParity.Parity_None
bytStop = RS232.DataStopBit.StopBit_1
oCP2.Open(intCommPort2, intBaud, intData, bytParity,
bytStop, 4096)
tmrRead.Enabled = True
MenuItem2.Enabled = False
MenuItem3.Enabled = True
ToolBar1.Buttons(0).Enabled = False
ToolBar1.Buttons(1).Enabled = True
TextBox1.Enabled = True
TextBox2.Enabled = True
btnClear.Enabled = True
Me.btnSendTable.Enabled = True
_IndicatorCOM2 = intCommPort2
End If
'_COMPortIndex += 1
Next
End Sub
Public Overloads Sub Open(ByVal Port As Integer, _
ByVal BaudRate As Integer, ByVal DataBit As Integer, _
ByVal Parity As DataParity, ByVal StopBit As DataStopBit, _
ByVal BufferSize As Integer)
Me.Port = Port
Me.BaudRate = BaudRate
Me.DataBit = DataBit
Me.Parity = Parity
Me.StopBit = StopBit
Me.BufferSize = BufferSize
Open()
End Sub
Public Overloads Sub Open(ByVal Port2 As Integer, _
ByVal BaudRate As Integer, ByVal DataBit As Integer, _
ByVal Parity As DataParity, ByVal StopBit As DataStopBit, _
ByVal BufferSize As Integer)
Me.Port = Port2
Me.BaudRate = BaudRate
Me.DataBit = DataBit
Me.Parity = Parity
Me.StopBit = StopBit
Me.BufferSize = BufferSize
Open()
End Sub