Program to read Data From Comm Port

Hello ,
         I am trying to receive data from serial port
( RS232) COMM2 .Give me some ideas to program to get data and to display them.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

For a full code tutorial on reading to and sending from the com port:

A good tutorial on the MScomm control:

You have to make certain that both terminals are configured for the same Baud Rate, Number Of Stop Bits, Number Of Data Bits and Parity Bits. With this not set right, Baud rate mismatch, data mismatch or parity error can occur. This is done with the VB code.

When using the MScomm control, you need to set the properties:

Private Sub Form_Load()
    MSComm1.CommPort = 1                  'CommPort to use
    MSComm1.Settings = "9600,N,8,1"     'Setting BaudRate, Parity (Yes, No, Even), Number of Data Bit, Number of Stop Bits
    MSComm1.InputLen = 0                
    MSComm1.PortOpen = True               'Open the port
End Sub

Private Sub Form_Unload(Cancel As Integer)
    MSComm1.PortOpen = False               'Close the port on form Unload
End Sub

To read from the port:

Private Sub MSComm1_OnComm()
 Dim buffer As Variant
 Select Case MSComm1.CommEvent
  Case comEvReceive
  buffer = MSComm1.Input
  Text1.Text = Text1.Text & buffer
 End Select
End Sub

To send from the port:

Private Sub cmdSend_Click()
 MSComm1.Output = "000000001" + chr$(13) 'chr$(13) is used as a carrige return not necessary somtimes
End Sub

You might also need a null modem cable to simulate the handshaking signals, for proper communication. The null modem is connected to facilitate the connection of 2 "DTE" or 2 "DCE". The cable wiring is important, here is some info on that:


To ensure it's done correctly, you can buy pre-made null modem cables, as well as connectors for around $1.50. Check this site for info

As for displaying the data, how do you want to do this? Chart form table text box?

You can VB / Excel OLE automation :

HOWTO: Create Excel Chart w/OLE Automation from Visual Basic;en-us;q142387

Excel Automation:
Controlling Excel from a Visual Basic Application

You can also use the chart control:;EN-US;Q275649&ID=KB;EN-US;Q275649&sd=msdn&

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Any Luck??
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ/No Refund
Please leave any comments here within the next seven days.


EE Cleanup Volunteer

I think i provided more than enough information on what the asker required.

VB Page Editor
Experts Exchange

I agree, but I have no way to test it and the asker did not reply to your posts.

EE Cleanup Volunteer
PAQed - no points refunded (of 500)

EE Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.