MSCOMM returning garbage as input

M

Marty

I created a form and put the mscomm object on it. i am using this code and
it doesn't work. The mscomm1.input returns junk.

please help.

Private Sub CommandButton1_Click()

If UserForm1.MSComm1.PortOpen Then
MsgBox (UserForm1.MSComm1.PortOpen)
Exit Sub
End If

UserForm1.MSComm1.CommPort = 2
UserForm1.MSComm1.Settings = "9600,N,8,1"
UserForm1.MSComm1.InputLen = 0
UserForm1.MSComm1.InputMode = comInputModeText
UserForm1.MSComm1.RTSEnable = True
UserForm1.MSComm1.Handshaking = comRTSXOnXOff
UserForm1.MSComm1.RThreshold = 1
UserForm1.MSComm1.PortOpen = True


MsgBox (UserForm1.MSComm1.PortOpen)
UserForm1.Show


and the oncomm event on the control

Private Sub MSComm1_OnComm()
MsgBox ("Hello Marty1")

MsgBox UserForm1.MSComm1.Input
'Range("B9").Select
' ActiveCell.FormulaR1C1 = Left(MSComm1.Input, 10)
' Debug.Print MSComm1.Input
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top