Hello everybody
How to show usb drive letter when we attach my usb to my computer
example:
we use a label or textbox and one timer
now we want to do this we start my project and attach a usb drive to my pc
the lebel or textbox show much fast my usb storage device drive letter ( I:\ or f:)
please tell me a good solution

Add Reference : Microsoft Script Runtime
Add 1 label.

Private Sub SysInfo1_DeviceArrival(ByVal DeviceType As Long, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)
Call Check
End Sub

Private Sub SysInfo1_DeviceRemoveComplete(ByVal DeviceType As Long, ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceData As Long)
Call Check
End Sub

Private Sub Check()
Dim FSO As New Scripting.FileSystemObject, drv As Scripting.Drive
'No Usb Detected
Label1.Caption = "Drive : -"

For Each drv In FSO.Drives
    If drv.IsReady Then
        If drv.DriveType = Removable Then
            Label1.Caption = drv.DriveLetter & ":"

        End If
    End If
Next
End Sub

Private Sub Timer1_Timer()
Call Check
End Sub

Thanks Jxman code is right work but i have a problem please tell me whats wrong
when we start project the system work very slowly and second problem
we use a portable vb6 in home and use a full installation software of vb6 in my work shop
when we use a portable vb6 at home and when we start a project or compile any application the avast
antivirus say it is a malicious program and close the program
by the way this code is work just you reply what i do and we mark solve this thread
Thank Jxman

Edited 4 Years Ago by razamughal67

I'm currently using Avast antivirus and there's nothing alert when i run the compiled application.
I don't know if this happen caused by portable vb6 since i'm using the full installation.

This question has already been answered. Start a new discussion instead.