Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6 VB
How we can test whether USB Device is connected or disconnected?
Please help for code in VB 6.0
Posted 23-Jan-12 22:02pm
Edited 23-Jan-12 22:07pm
v2
Comments
pashad at 24-Jan-12 3:07am
   
Always use small letters while posting your question/s.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Here i provide the solution .........
Function IsComPortAvailable(ByVal portNum As Integer) As Boolean
    Dim fnum As Integer
    On Error Resume Next
    MSComm1.CommPort = portNum
    MSComm1.PortOpen = True
        If Err = 0 Then
            MSComm1.PortOpen = False
            IsComPortAvailable = True
        End If
    End Function
 
For i = 1 To 16
        If IsComPortAvailable(i) Then
        Combo1.AddItem (i)
        End If
    Next
 
Keep this code in timer and fix timer for 5 sec then it may show you every 5 secs which ports are available ...........
  Permalink  
v2
Comments
Sergey Alexandrovich Kryukov at 29-Jun-12 13:43pm
   
What is MsComm1? You don't show where it is declared. Unfortunately, COMM ports have nothing to do with USB. First of all, USB is not even a port (despite the common misconception), it is a bus. Sorry, I just have to vote 1 for this answer. Again, the principle "make no harm" is more important here. It's much better not to answer on the topic you don't know, because a wrong answer can confuse OP, lead to a huge waste of time, on other words, cause harm.
 
Sorry,
--SA

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 334
1 Kornfeld Eliyahu Peter 325
2 Maciej Los 239
3 OriginalGriff 188
4 King Fisher 185
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 24 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100