Today is...
Tuesday, January 27, 2015
Welcome to, the global online
community of automation professionals.
Featured Video...
Featured Video
EtherCAT with CTC’s master lets your multivendor network play well together...
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
Sample USB port program in Visual Basic
Can someone please provide me the sample code for USB port programming in VB6?


Can someone please provide me the sample code for USB port programming in VB6?

email: to.go @ gmx. de


By Robert Scott on 20 March, 2008 - 12:19 am

There is no such thing as simply writing to a USB port in VB6. You write to devices that just happen to be on the USB port. Each device can have its own driver and therefore its own interface with VB6.

If you are thinking of writing to a USB-hosted serial port, then you would just access that port the same as if it were a legacy serial port, by name ("COM1", "COM2", etc.). So instead of trying to figure out how to talk to USB, just figure out how to call a serial port in VB6. I know how to do it in C++ using the Win32 API, but I don't know the VB6 equivalent.

Robert Scott
Real-Time Specialties
Ypsilanti, Michigan

By Jose Auugusto on 1 April, 2008 - 12:15 am

Hello Robert,

Can you send your C++ implementation of USB to me?
I'm trying to do this but I'm not finding much content on the internet.


Jose Augusto Stuchi
gutousp @ gmail. com
University of Sao Paulo - Brazil

By Robert Scott on 1 April, 2008 - 11:30 pm

I said there is no such thing. Most people who ask for USB code are really asking for serial code to talk to a USB-to-serial converter. If this is what you want, then don't look for code for USB. Look for code for serial communication. A good place to start is Microsoft's MSDN web site:

Robert Scott
Real-Time Specialties
Embedded Systems Consulting

This is merely a link to some resources. I will not support or explain the code.

Does it work the same way with a parallel port device converter to usb; Cause i have a code on C++ builder to control a device from parallel port. The same code would control the device with the converter.

Thank you.

I am also looking around for docs in serial communication with C++ but I cannot find anything. Is there a component in C++ like the MSCOMM in VB for serial com? If yes, what is it in C++? Can you please give me some clues or send files which can help me for a start?

I would realy appreciate that. Thanks.

Since you are using C++, you do not need an object like MSCOMM. Use the file I/O API to open, read and write a COMx port. It is not difficult.


But how do I do that Bill? I have never done port communication or such things. Can you please give the procedure and a sample of code? Thanks.

nnalarissa @ gmail. com

Hi dear..

I also want to make project on port programming but coding must be in VB 6.0, it's a strict rule in our university.

So will you please tell me some basics about how to use the USB ports in VB? Please reply to me, it's compulsory for me... I hope you will help me...


If anybody what to use their parallel port for controlling devices, you can relay on me. I have the program in VB6. I will help you.If interested contact me.

email:staytunedfriends [at]

By Jaime Colon on 7 February, 2011 - 3:40 pm

Please help me with this...please do share...

By Mitchel Jammal on 21 February, 2011 - 8:03 pm

Hi, if you still want a USB example for VB6, please write me at my e-mail, IŽll send back you a example in VB6 code.

Best regards.


By steve floyd on 3 April, 2008 - 12:43 am

Use the mscomm procedure to write to your com ports.

Something I threw together a while back. Useful for generic playback of captured USB HID stream to devices.


Do you get any sample code for USB port programming in VB6?
plz send me any of it

By Kees Norren on 8 November, 2010 - 9:35 am


Did you get it ?
please forward to knorren [at]

Tnx Kees

hiya could u email me the vb6 code for the usb , thanks

rafakat.hussain [at]

Could someone also forward that email to myself please (


Please someone forward it to me at


If you google:vb6 com port
you quickly find your information.
For example:

What also might be of interest is

how we do it in C++:

What type of trouble you might have with USB/Serial adapters under Windows:

PS: together with scripting in Lua might be easier for you than Basic.

can you also forward to my mail the usb codes. thanks


i understand about parallel ports but not bout usb ports.

like the 8 bit data is send through 8 data pins in parallel ports, then how is it done in usb port?

pls help me out this.....

Its not called a universal SERIAL port for nothing.

ok, whatever it is .... i said, i didn't have knowledge about it.
plz can you tell me something worth telling... ???

By Robert Scott on 14 May, 2012 - 8:16 am

The best reference I have found to USB workings is the book "USB Complete" by Jan Axelson. But be advised that if you intend to do anything original with USB itself then you are going to have to do a lot of work - I mean years. Most people who use USB do not do anything original with it. They use manufacturer-supplied drivers for specific USB devices, like serial ports, printers, mice, and custom data acquisition equipment. Unless you are a top-level USB developer with years of experience in the field you are not going to use USB without going through one of these manufacturer-supplied device drivers, and these drivers are custom made for each device that plugs into the USB.

thnx dude! well, do you have e-book or pdf format of the book you mentioned?

oh ! i got it, its available there on the net.
well how do you know that it requires xpirience?

By Robert Scott on 16 May, 2012 - 1:36 pm

> oh ! i got it, its available there on the net.
> well how do you know that it requires xpirience?

Because I read it.