How to send data to COM port using VB

Hello all,
i need a sample code to send text on COM Port. I am doing a project on Bank and need to display current token no on Display board which is connected to my CPU on COM1 port.

Thanks in advance.
nirmal_4194Asked:
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.

Mikal613Commented:
http://www.codeworks.it/net/VBNetRs232.htm

Initializing and Opening the Com port

Create an instance of CRs232 then set COM parameters before invoking the Open method
Here's an example:
Dim moRS232 as New Rs232()
With moRs232
           .Port = 1                                                      '// Uses COM1
           .BaudRate = 2400                                        ' // 2400 baud rate
           .DataBit = 8                                                 ‘// 8 data bits                                                  
           .StopBit = Rs232.DataStopBit.StopBit_1         '// 1 Stop bit
           .Parity = Rs232.DataParity.Parity_None           '// No Parity
           .Timeout = 500                                             '// 500 ms of timeout admitted to get all required bytes
End With
'// Initializes and Open
moRS232.Open ()
You can, optionally control the state of DTR/RTS lines after the Port is open
  '// Set state of RTS / DTS
moRS232.Dtr = True
moRS232.Rts = True

In case of an error/problems an exception is raised, so i suggest you to enclose the code within a Try...Catch block.

Transmitting data to COM Port
The class has 2 buffers one for Tx and one for Rx, to transmit data just set the TxData property with the informations you wish to send then invoke the Tx method.
example:
moRS232.Write(txtTx.Text)


0

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
nirmal_4194Author Commented:
hi Mikal613  feedback

thanks for your coding.

i could not able to find the reference of Rs232. Can you tell me what reference or controls i need to add in my project to use this code.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.