Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am working on a project which need vb to detect and communicate with 2 usb devices. I am quite new to VB. I would like to know how vb detect which usb port the device is connected to. Send me the source code if you can. My email is *REMOVED MAIL*.

Btw, I had downloaded and look at the code from http://www.microsoft.com/downloads/e...DisplayLang=en. I understand this code is used for serial com RS232. Will it work for USB?

Thanks.
Posted
Updated 15-Feb-11 19:41pm
v2
Comments
Sandeep Mewara 16-Feb-11 1:41am    
why asking for a source code?

Did you try anything? Any effort?
JF2015 16-Feb-11 1:42am    
Removed mail address since you will get an automated reply from CP if someone answers your post. BTW, your link is not working.
[no name] 16-Feb-11 22:07pm    
Actually i do not have the USB device with me so I cannot test the source code. I will be using one GPRS Modem. Anyone who is an expert in this field?

1 solution

There is nothing exceptional in accessing USB drive in VB.Net.
You can make use of DriveInfo (Syste.IO namespace) class to access the removable device like USB.
There is a property IsReady which tells whether USB device is connected or not.

Find some good examples on drive info (they are all in C#)
1. http://www.majstro.com/Web/Bedrijf/cs/cs_System_IO_DriveInfo.html[^]
2. http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx[^]
 
Share this answer
 
Comments
[no name] 16-Feb-11 22:08pm    
is this only for disk drives? I need to communicate with these devices? will it work?
Pravin Patil, Mumbai 17-Feb-11 4:10am    
Which devices are you talking about Lim?
This will work for USB devices, Disk Drives, Removable Media etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900