R
My program in VB6 makes use of the serial port which is connected to a keypad module wirelessly through zigbee. Anyway, when I open the serial port (Comm port 1), there are no problems. I get to receive and interpret the data correctly. however, when I use a serial to usb converter, it doesn't work (I opened the correct port, it's port 4 when I'm using the converter). I'm sure that the usb to serial converter works properly. because when I simulate data transmission using real term, the data is properly sent and received through the converter. however, I can't make this work when I'm running the program.. Can anyone help me here? >.< I'm desperate.
Here's the code I used to open the port:
'Open and Close port Functions
Public Function PortOpen() As Integer '1 = Successful, 0 = Failure
'Open the port
With MSComm1
.CommPort = cmbPort.ItemData(cmbPort.ListIndex)
.Settings = "9600,N,8,1"
.InputMode = 0
.InputLen = 0
.RThreshold = 1
.SThreshold = 1
.DTREnable = True
.RTSEnable = True
.NullDiscard = False
If .PortOpen = False Then
On Error GoTo OpenPortErrorHandler
.PortOpen = True
PortOpen = 1
OpenPortErrorHandler:
If Err.Number = 8002 Then
MsgBox "You are attempting to open an invalid port. " & vbCrLf & _
"Kindly make sure that the RFID is connected to Port 1, then retry." _
, vbExclamation, Err.description
'Exit Function
PortOpen = 0
End If
Else
'Port is already open!
MsgBox "Port 1 is already open!", vbExclamation, "Port Open Check"
PortOpen = 1
End If
End With
End Function
Here's the code I used to open the port:
'Open and Close port Functions
Public Function PortOpen() As Integer '1 = Successful, 0 = Failure
'Open the port
With MSComm1
.CommPort = cmbPort.ItemData(cmbPort.ListIndex)
.Settings = "9600,N,8,1"
.InputMode = 0
.InputLen = 0
.RThreshold = 1
.SThreshold = 1
.DTREnable = True
.RTSEnable = True
.NullDiscard = False
If .PortOpen = False Then
On Error GoTo OpenPortErrorHandler
.PortOpen = True
PortOpen = 1
OpenPortErrorHandler:
If Err.Number = 8002 Then
MsgBox "You are attempting to open an invalid port. " & vbCrLf & _
"Kindly make sure that the RFID is connected to Port 1, then retry." _
, vbExclamation, Err.description
'Exit Function
PortOpen = 0
End If
Else
'Port is already open!
MsgBox "Port 1 is already open!", vbExclamation, "Port Open Check"
PortOpen = 1
End If
End With
End Function