Today is...
Sunday, December 21, 2014
Welcome to, the global online
community of automation professionals.
Featured Video...
Featured Video
A quick introduction to EtherCAT for motion control and I/O...
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
How to configure USB port in Visual Basic
How can I configure USB port in VB

Hello friends,
I want to connect USB port using VB How can I do that without using USB to RS232 converter? Can any one help me to know how can I connect USB port. I am using the device which uses data transfer at high speeds which cannot be supported using USB to RS 232 so can you please let me know how I can directly connect to the USB port using my GUI.

Thank you,
mail me back to

By Robert Scott on 15 October, 2005 - 8:57 pm

You don't say what USB device you wish to communicate with. The class of that device and the device driver associated with that device will dictate how you can access it in VB.

See the book "USB Complete" by Jan Axelson.

Robert Scott
Real-Time Specialties
Embedded Systems Consulting

I m using a Mitshibushi controller which is having USB feature and its belong to communication class. Actually we are developing this device so we have to configure the class in the software in the device side. We are using the driver provided by thesycon for this device

By Dr. R. Erlich on 12 November, 2005 - 12:17 am

VB GUI sample, DLL code and more--

EID, Corp. is an OEM manufacturer (100% made in U.S.A) for many kinds of E-USB boards and kits, such as I/O, ADC, timer, counter, etc. You will be able to control directly from your PC via USB port. Yes, free DLL and other free software...

Write your code, application utilizing our free DLL.

See the following links:

1. Free VB, C++ etc. DLL and demo software E-USB PC-ports kits:

2. Electronic Kit (DIY), I/O and more via E-USB:




I was searching the net for some FAQs on this exact subject so i thought I would jump the band wagon. I am a student and am working on a project at my school that requires me send 4 bit signals to a transmitter. the connection on the transmitter is connected via DB-9 serial, my problem is when I interface with my laptop there is no DB-9 present so i purchased a USB-SERIAL converter. Here is where im lost and i have lost my mind trying to figure this out. I have code written in VB however during the testing phase I wrote the code and tested at my home computer (using the DB-9 serial) and it worked fine. however when i used the adapter (USB) at my school I got all sorts of mscomm port errors. I was told that i had to modify my code to the USB. Any help here would be greatly appreciated.


I have a USB to serial that I bought for 78 bucks from radio shack, been using mine for 2 years now, have not found a thing that it has not worked with and I use mine at least once a week.

They still sell it.

But do you use it for VB 6.0? If so what is the brand maybe I could look for it?


Give me your e-mail address and I will send you some test source code in VB 6.

hi, i am also looking for VB6 code samples to control a USB-HID device, i would appreciate if you can also send one for me. thanks a lot.

Hey Starride,

here it is:


By Seth Fuller on 25 January, 2006 - 12:39 am

Hey Starride,

Please kindly send the VB6 example USB-Serial code to my email.


By Akhtar Hussain on 13 December, 2005 - 2:19 am

Dear sir,

Kindly give me the vbcode, how to cofigure USB port. I am using Righttag scanner to read & write data into tag using vbapplication.

Here is my e-mail address:

By Anonymous on 12 March, 2006 - 1:07 pm

Hey Starride,
Please kindly send the VB6 example USB-Serial code to my email.

Thanks, Mourad

By Anonymous on 5 April, 2006 - 11:49 pm

I am testing printer that hook to USB and I am using Visual Studios 2003. Do you have any code that will help me be able to communicate to these printers using VB or VB.Net. These printers are the ones you see in hospitals that make the id bracelets.


By Anonymous on 14 June, 2006 - 3:30 am

i'm also looking for vb or code to configure USB port.

pls kindly send the code to my email:


I m working in a manufacturing company. It would be gr8 to have the code in VB 6.0 that configures the USB port. Please send me the code on as soon as possible.

It would be really helpful...

hey starride, if ur still giving out that source code could you please send it to my email
...I'm working on a senior design project that requires me to take in data from a USB port.


I need also some help with Visual Basic to write USB driver. To be exact I need to send some ASCI strig over USB to another UNIT.

Here is my email:


Please Starride can I still have the test code for USB in VB6. Thank you. email addy is

plz five me the usb source code in vb 6. i really need it. this is my e-mail:

Hi Starride,

pls send me your source codes in VB6 or VB.NET. My mail:


By Anonymous on 24 April, 2007 - 1:27 am

If you have a code for connecting a scanner to VB or, please send it, I will grateful to you.

By Anonymous on 31 May, 2007 - 1:53 am

I'm a Spanish student. I'm investigating about connection USB with VB 6.0. Until now, in my view, the device and the conection type are not specifices (serial, bluetooth...).

If somebody has code for connecting some device with VB 6.0, please send it, I will be grateful to you.
potypoty55 @ yahoo. es


Could you please also send me details of the USB-Serial interface and VB source code?


I would be interested in your visual basic code, if you are still giving it out. My email is andy @ egl-neon. com. Thank you.

I would be interested in your visual basic code, if you are still giving it out. My email is KandM3301 at midsouth. Thank you.


I'm a student, and a need this code to conect and control a usb-bluetooth on vb6. Can you send me this code, please? Thank you very very very mch.

I also need the code to connect usb bluetooth on vb6.thanks

Hi Nisa,

USB - bluetooth devices are used as same as a serial port when you install your bluetooth device drivers.

So you can use it via MSComm (MSComm32.ocx) component with Visual Basic, it is not different than an ordinary RS232 port.

However, some bluetooth device drivers add two serial ports at the same time, one is used for sending and the other is used for receiving but it is a rare situation; most of the devices do receiving and sending in same serial port.

Hope this helps.
Industrial Automation Notes: A blog about PC managed automation systems.

Please send me
farzadmn2 @ yahoo. com

Also when I used searching Engine for the same titles I found this which is more more important for me, please send me this code for configuring the USB port through VB6

>Give me your e-mail address and I will send you some test source code in VB 6. <

I create a project in 2008 and I'd like a help with configure a USB port.

My email is astef31 [at]

pls give me fast vb code if u have vb 205 usb code so please send to me.

keval_savanim [at]

this is my email address

>Give me your e-mail address and I will
>send you some test source code in VB 6.

To Starride and those who can help me,

I 'm a student and I want to connect USB port using VB or VC++ with parallel port or serial port to control devices. I am using windows 7 64 bit and facing problem now.

How can I do?
Where can I find dll files and mscomm ... to help me?

Please kindly send the VB6 example USB-Serial code to my email
My email is :

Oh how old threads die a long slow death...


MSCOMM must have pin 1 of the DB9 serial point at a high level or it will not initialize. Dumb limitation but a fact to deal with.

I dont think you need to change your code, this is a similar problem i had while communicating with a PLC.

The serial converter sets itself up (with the help of the driver) as a standard com port.
So you need to go into control panel/system/ports and check which port it has assigned for the adapter eg com1/com2 etc.then you can set up your mscomm port settint to the correct port value.Beware if you have more than one USB port and you plug your serial adapter into a different one the computer will re assign a new com port number.

hope this helps

By Anonymous on 2 August, 2006 - 9:55 am


I 'm a student and I want to connect the PPC to other device (such as microcontroller) across USB port. Hence i need some help.

pls kindly send the source code to my email:

Thank you very much!

If you want to connect your PC to microcontroller through USB port,your microcontroller must have USB port or you have to buy additional IC that convert USB to serial.
For example you can check and search for ft232bm. It is USB to RS232 convertor.

I you have any problem you can mail to me.


I have interface with 24 I/O contact to the PC through USB and I want to use this interface to control 24 LED by switch ON/OFF each one separately. So, I will be so grateful to you if you can help me by send me any code in VB to do that.
Thanks in advance
Please send your answer to my

By Robert J Reeder on 11 March, 2011 - 9:00 am

I use RS232-USB devices all the time.


In a couple cases, I had to run a ground wire from the 15 pin video outlet across to the RS232 device. If the Ground is allowed to 'float', USB operation will be intermittent.


By Nathan Boeger on 12 March, 2011 - 4:21 am

> I use RS232-USB devices all the time.

Could you explain how you do this in a little more detail? Thanks,

Nathan Boeger

By Sarim Khan on 16 June, 2009 - 9:30 pm

I am a visual basic programmer. I used parallel port for sending and receiving data between PC and hardware. Now I want to use USB port to send and receive data. Can anyone send me the code and how to build hardware for usb?

my email is


I 'm a student and I want to connect USB port using VB or VC++ with a full speed rate. How can I do? Where can I fing dll files... to help me?

Thank you,
mail me back to


I'm also doing some testing that access to USB port. Is there anyone who has the VB code for this? Please forward it to me at

Thank you very much.


I'm working on my thesis, and I'm in bad need to the VB6 source code to access the USB port for a custom device (FPGA developed USB device), and also for a printer that I'm having some problems to deal with.
I do appreciate it if you can send me this code. or

Thank you very much! :)

Bob (on this thread) had the best advice... If you're converting from USB to serial device (i.e. newer laptop/PC to older device), you must have a USB to serial cable, install the drivers that come with it; reboot your pc; plug in the USB cable (doesn't have to be connected to device on other end); go to Control Panel, "Ports" to confirm it's now enabled in Windows and to see which Comm port it is now - mine was Comm 4. Finally, go to the VB code and edit it to find Comm 4. In my case, the code was originally, "MSComm1.CommPort = 1" I simply had to change it to "MSComm1.CommPort = 4".

Hope this helps.


I'm doing the same you did. If you had some news can you forward to me at marchesani.enrico @ libero. it?

Thank You.


I'm working on a thesis where my microcontroller sends data vis serial, but I have to use USB to connect it up to my computer. I would really appreciate it if someone could send me the code that was discussed above to my email.

r. panthaky @ hotmail. com

Thank you so much.


I am working in communicating a Thrustmaster joypad with B to control servos. If anyone could pass me some code, I would be very grateful.

manin1952 @ hotmail. com


Hi all,

Please can anyone send me some code for controling the USB port using VB.NET? Send them to: t_adison @ Hotmail. com

I will need to control my USB port in my project, so I am doing some research to obtaine some code but it sucks!

Any help?

Thank you very much.

Hi all,

Can you forward the VB6 code and details regarding that to me also? I am doing a project where I have to send data to a kit via USB port from the GUI.

Therefore I need this code. My id is kollu. kavya @ gmail. com

By Anonymous on 5 June, 2008 - 12:31 am


Can you forward to me the code too...

heero06 @ gmail. com

Hi ,
Can I have the copy OF VB source please .
Thanks in advance.
Ashkan Golestani

ashkan.golestani [at]

I had similar requirement and the following is what I did:
a) downloaded a VIRTUAL SERIAL PORT (VSP) from FTDI and installed on the PC (

b) Then, when you connect the USB instrument, I noticed an added COM port in the SYSTEM (COM7 in my case).

c) I, then, used MSCOMM1 in VB6 to communicate to the device.

I would use Python and PyUSB instead.

Romulo Rodriguez

By Lim Choon Kiat on 20 October, 2008 - 12:08 am

Hi there,

I went to the site to download driver version 2.04.06. (It comes with the file "CDM 2.04.06")

However, when I run that file on my XP box, nothing seem to happen. What did I do wrong? (Or is there any configuration I need to do?) Please advise me.

You may email me: limchoonkiat at live. com


I have done the same thing but i am using VisualStudio 2008 and i can't seem to find a way to use MSComm. Any ideas?

> I have done the same thing but i am using VisualStudio 2008 and i can't seem to find a way to use MSComm. Any ideas? <

VS2005/2008 no longer uses MSComm, you need to reference System.IO.Ports. From there you will have access to the SerialPort object.

By Mohamed Haseel on 24 February, 2011 - 10:57 am

i'm also in the same problem that i don have a rs232 port on my lap. so i purchased a usb to rs232 converter. but since i've programmed using vb6.0 for my rs232 port, i need them to be converted for the new converter that connects using usb port.

please send solutions if any to my email..

I'm also having some problems with configuring the usb port in VB. Could you please send me some source codes showing how to do it.

My e-mail is

By simplicio on 4 May, 2011 - 6:10 pm

Please visit:

Interface WindForms USB Control for Visual C# and VisualBASIC.NET to connect with microcontroller.