PDA

Click to See Complete Forum and Search --> : VB6 Comm Control in XP - Error 8015


markjdixon
Mar 12th, 2004, 09:14 AM
Can anyone help with a problem I am having with VB6/WinXP.

The COMM control will not read any information from COMM port 1.

It does however give error 8015....

My code works fine in Win98.

I have checked in HyperTerminal to ensure that the signals are being received into COMM1.

Here is the (relevant) App code.

' Error handling
On Error GoTo ErrorHandler:

'Buffer to hold input string
Dim comm1Input As Variant

' Use COM2.
mdiMain.MSComm1.CommPort = 1
' 9600 baud, even parity, 7 data, and 1 stop bit.
mdiMain.MSComm1.Settings = "9600,E,7,1"
' Tell the control to read entire buffer when Input
' is used.
mdiMain.MSComm1.InputLen = 0

' SG balance (NTC) starts with '?' for valid return (example: '? 194.3 g')
' PM balance (ETC) starts with ' ' for valid return (example: ' 194.3 g')
Do Until Left(comm1Input, 2) = "? " Or Left(comm1Input, 2) = " "

' Respond to any other events
DoEvents

' Open the port.
mdiMain.MSComm1.PortOpen = True

' Read the rest of the input from the serial port
comm1Input = mdiMain.MSComm1.Input

' Close the serial port.
mdiMain.MSComm1.PortOpen = False
Loop

'extract weight from the input string and return
getWeight = Val(Mid(comm1Input, 3, Len(comm1Input) - 5))

' Exit before error handler
Exit Function

' Error handling
ErrorHandler:
If Err.Number <> 0 Then
Call MsgBox("Error Recorded, please contact System Administrator", vbCritical, "Error")
Call errorLogger(Err.Number, Err.Description, "modGlobalCode")
End If

End Function