Solved

How to detect a mini Device storage (128kb)from inside of mi application?

Posted on 2004-08-16
4
195 Views
Last Modified: 2013-11-15
Hello I have those mini device storages 128kb and I need  to detect automatically from inside of my aplication and import data from it. Right now I use the drivelistbox to detect what letter, but my problem is when somebody don't know what letter is the mini device storage they try to select the others drives list in this combo drivelistbox but giving this as an error which I don't know how to filter that error.
Could somebody tell me how to detect this mini device storage automatically?
Thanks a lot
Daniel
0
Comment
Question by:danielmingolla
  • 3
4 Comments
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11807880
Try this (need reference to Microsoft Scripting Runtime)

Dim oFSO        As Scripting.FileSystemObject
Dim oDrive      As Scripting.Drive
Dim sType       As String
Dim sMsg        As String
   
    Set oFSO = New Scripting.FileSystemObject
   
    For Each oDrive In oFSO.Drives
        Select Case oDrive.DriveType
            Case 0: sType = "Unknown"
            Case 1: sType = "Removable"
            Case 2: sType = "Fixed"
            Case 3: sType = "Network"
            Case 4: sType = "CD-ROM"
            Case 5: sType = "RAM Disk"
        End Select

       
        sMsg = "Drive " & oDrive.DriveLetter & ": - " & sType
        If oDrive.IsReady Then
            sMsg = sMsg & " - Drive is Ready."
        Else
            sMsg = sMsg & " - Drive is not Ready."
        End If
       
        Debug.Print sMsg

    Next
   
    Set oFSO = Nothing

Drive should be ready, and it's type should be Removable. Also you should check oDrive.TotalSize. HTH
0
 

Author Comment

by:danielmingolla
ID: 11812748
Hello and thanks for your answer!!
Your sample looks like if what I need but is not working is not doing nothing I put all your code in a form in the load event and referenced to microsoft scripting but is not doing nothing neither the msgbox appear, could you please let me know what I am doing wrong!!
Thanks again
Daniel
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11812928
Private Sub Form_Load()
Dim oFSO        As Scripting.FileSystemObject
Dim oDrive      As Scripting.Drive
Dim sType       As String
Dim sMsg        As String
   
    Set oFSO = New Scripting.FileSystemObject
   
    For Each oDrive In oFSO.Drives
       
        If oDrive.IsReady Then
            If oDrive.DriveType = Removable And oDrive.TotalSize = 64274432 Then
                MsgBox oDrive.DriveLetter
            End If
        End If
       
    Next
   
    Set oFSO = Nothing
End Sub

64274432 is size of my USB flash device (64 MB). Replace this with size you need (128 MB = 64274432*2)
0
 
LVL 8

Accepted Solution

by:
mladenovicz earned 125 total points
ID: 11812946
Private Sub Form_Load()
Dim oFSO        As Scripting.FileSystemObject
Dim oDrive      As Scripting.Drive
Dim sType       As String
Dim sMsg        As String
Dim bFound      As Boolean
   
    Set oFSO = New Scripting.FileSystemObject
   
    For Each oDrive In oFSO.Drives
       
        If oDrive.IsReady Then
            If oDrive.DriveType = Removable And oDrive.TotalSize = 64274432 * 2 Then
                MsgBox oDrive.DriveLetter
                bFound = True
            End If
        End If
    Next
   
    If Not bFound Then MsgBox "Device can not be found"
   
    Set oFSO = Nothing
End Sub
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now