Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gett9ing input from a serial port

Status
Not open for further replies.

mtek13

Programmer
Aug 23, 2001
24
0
0
CA
Hi,

I am trying to read the weight from a libra connected to a serial port. If someone knows hoe to do it please reply.

Regards Mo
 
Add a Microsoft MSComm to your form and try this.

Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeText
MSComm1.PortOpen = True
End Sub

Private Sub MSComm1_OnComm()
Dim Data as String
Select Case MSComm1.CommEvent
case comEvSend 'Send event.
Data = MSComm1.Input
end select
End Sub

Hope it helps
 
It still doesnt work,
Tha balance i am using displays an error when i am sending strings to it but it does not retrive any bit from it.

Mo
 
Make sure that your code has the port that you are using and that the inputmode is set to what you are using.

 

This is actually my code, and i tried different ways and still doesnt work:

Private Sub MSComm1_OnComm()
Dim Data As String
Select Case MSComm1.CommEvent
Case comEvSend
Data = CStr(MSComm1.Input)
End Select
Text1 = Data
End Sub

Private Sub Timer1_Timer()
Call MSComm1_OnComm
End Sub

Thanks anyway,
 
By the way, you shouldn't need the timer. If you have the port open, it will call the OnComm event when something hits the port.
 
AND you have to set the RThreshold property of the control to a value other than 0 (which is the default) to receive the comEvReceive events.
Greetings,
Rick
 
If you have any program that you know it works it will be helpful to see if my balance has actually problems or its only my coding or configuration
 
Maybe you should hook up a protocol analyzer between your pc and your device. At least you know then if you're actually getting any data from the device or not.
Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top