ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MSCOMM returning garbage as input (https://www.excelbanter.com/excel-programming/338620-mscomm-returning-garbage-input.html)

Marty[_5_]

MSCOMM returning garbage as input
 
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




All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com