from the Automation List department...
Sample USB port program in Visual Basic
Application Questions and Problems topic
Posted by Tom on 19 March, 2008 - 12:29 am

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

email: to.go @ gmx. de


Posted 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

Posted 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

Posted 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

Posted by CTTech on 3 April, 2008 - 1:00 am
This is merely a link to some resources. I will not support or explain the code.

Posted by Jim on 17 January, 2011 - 4:56 am
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.

Posted by Larissa on 9 April, 2008 - 12:17 am
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.

Posted by Bill Code on 10 April, 2008 - 11:53 pm
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.


Posted by Larissa on 17 April, 2008 - 12:09 am
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

Posted by raj on 11 June, 2008 - 12:20 am
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...

Posted by Ron on 15 August, 2010 - 9:15 am

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]

Posted by Jaime Colon on 7 February, 2011 - 3:40 pm
Please help me with this...please do share...

Posted 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.


Posted by steve floyd on 3 April, 2008 - 12:43 am
Use the mscomm procedure to write to your com ports.

Posted by Unknown on 28 May, 2008 - 1:25 am
Something I threw together a while back. Useful for generic playback of captured USB HID stream to devices.

Posted by Aziz on 19 October, 2010 - 5:44 am

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

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

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

Tnx Kees

Posted by raf on 19 November, 2010 - 6:24 pm
hiya could u email me the vb6 code for the usb , thanks

rafakat.hussain [at]

Posted by Matt on 23 January, 2011 - 10:30 pm
Could someone also forward that email to myself please (


Posted by Dave on 2 November, 2011 - 8:06 pm
Please someone forward it to me at


Posted by pvbrowser on 3 November, 2011 - 6:38 am
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++: tml

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.

Posted by Apol on 11 December, 2011 - 10:41 am
can you also forward to my mail the usb codes. thanks

Posted by zubeen on 10 May, 2012 - 9:17 am

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.....

Posted by o\ on 10 May, 2012 - 10:41 am
Its not called a universal SERIAL port for nothing.

Posted by Zubeen on 12 May, 2012 - 1:48 pm
ok, whatever it is .... i said, i didn't have knowledge about it.
plz can you tell me something worth telling... ???

Posted 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.

Posted by Zubeen on 15 May, 2012 - 2:30 pm
thnx dude! well, do you have e-book or pdf format of the book you mentioned?

Posted by Zubeen on 15 May, 2012 - 2:34 pm
oh ! i got it, its available there on the net.
well how do you know that it requires xpirience?

Posted 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.

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2014 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.

A chubby man with a white beard and a red suit will approach you soon.
Avoid him. He's a Commie.
Advertise here
our advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive