To read from COM port
Hi,
I have a weighing m/c connected with COM port of my system .I want to read a set of data from it.I want to know wether it would be advisable to do in c++ or in VB?Can anybody guide me how to do the same.
Thank you!
Web Development
Hi,
I have a weighing m/c connected with COM port of my system .I want to read a set of data from it.I want to know wether it would be advisable to do in c++ or in VB?Can anybody guide me how to do the same.
Thank you!
by johnfriz
Hi,
Assuming that you have VB5 or 6, you should have access to the MSComm control. (if not you can download an Active X wrapper for it here: http://ourworld.compuserve.com/homepages/richard_grier/xmcomm.htm This page also hase a lot of good info on reading from/writing to COM ports)
Here is a simple example using the MSComm control
' Buffer to hold input string
Dim Instring As String
' Use COM1.
MSComm1.CommPort = 1
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True
' Wait for data to come to the port.
Do
DoEvents
Loop Until MSComm1.InBufferCount >= 1
Read the info from the port
Instring = MSComm1.Input
' Close the serial port.MSComm1.PortOpen = False
Regards,
John.
This discussion is closed to new replies.
Sort by Trending