Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Visual Basic 6 - Drive in una textbox
Forum - Visual Basic 6 - Drive in una textbox

Avatar
swet (Normal User)
Pro


Messaggi: 128
Iscritto: 01/01/2009

Segnala al moderatore
Postato alle 16:07
Giovedì, 01/01/2009
Ciao a tutti ho provato a cercare col il tasto cerca ma ho ottenuto solo una pagina di errori quindi posto qui il mio quesito!

Ho scaricato questa porzione di codice dal msdn di microsoft per riconoscere e scrivere nel msgbox le lettere delle unità.
Codice sorgente - presumibilmente VB.NET

  1. Private Sub Command1_Click()
  2. Dim strDrives As String
  3.    
  4.  
  5.     ' Find out what drives we have on this machine
  6.     strDrives = GetDriveStrings()
  7.    
  8.     If strDrives = "" Then
  9.         ' No drives were found
  10.         MsgBox "Nessun drive trovato!", vbCritical
  11.     Else
  12.         ' Walk through the string and check the type of each drive
  13.         ' displaying any cd-rom drives we find
  14.         Dim pos As Long
  15.         Dim drive As String
  16.         Dim drivetype As Long
  17.        
  18.         pos = 1
  19.         Do While Not Mid$(strDrives, pos, 1) = Chr(0)
  20.             drive = Mid$(strDrives, pos, 3)
  21.             pos = pos + 4
  22.             drivetype = GetDriveType(drive)
  23.            
  24.             If drivetype = DRIVE_CDROM Then
  25.            
  26.                 MSGBOX ( UCase(drive))
  27.            
  28.        
  29.             End If
  30.         Loop
  31.     End If
  32.  
  33. End Sub


il mio problema è che voglio prendere le lettere delle unità e metterle in una textbox tutte insieme. Ho provato sostituendo msgbox ( UCase(drive)) con text1.text = ( UCase(drive))

ma mi scrive solo l' ultimo lettore cd. NOn so se mi sono spiegato!grazie

EDIT ho risolto così:
Codice sorgente - presumibilmente VB.NET

  1. Private Sub Command1_Click()
  2. Dim strDrives As String
  3.    
  4.  
  5.     ' Find out what drives we have on this machine
  6.     strDrives = GetDriveStrings()
  7.    
  8.     If strDrives = "" Then
  9.         ' No drives were found
  10.         MsgBox "Nessun drive trovato!", vbCritical
  11.     Else
  12.         ' Walk through the string and check the type of each drive
  13.         ' displaying any cd-rom drives we find
  14.         Dim pos As Long
  15.         Dim drive As String
  16.         Dim drivetype As Long
  17.        
  18.         pos = 1
  19.         Do While Not Mid$(strDrives, pos, 1) = Chr(0)
  20.             drive = Mid$(strDrives, pos, 3)
  21.             pos = pos + 4
  22.             drivetype = GetDriveType(drive)
  23.            
  24.             If drivetype = DRIVE_CDROM Then
  25.            
  26.                 Text1.Text = UCase(drive)
  27.            
  28.        
  29.             End If
  30.             Text2.Text = Text1.Text & Text2.Text
  31.            
  32.         Loop
  33.        
  34.     End If
  35.  
  36. End Sub


ora però nella text2.text ho delle lettere uguali tra loro sapreste indicarmi cosa corregere? oppure se esiste un metodo per cancellare le lettere uguali tra loro? grazie e buon anno!

Ultima modifica effettuata da swet il 01/01/2009 alle 16:52
PM Quote
Avatar
GrG (Member)
Guru^2


Messaggi: 3430
Iscritto: 21/08/2007

Segnala al moderatore
Postato alle 16:50
Giovedì, 01/01/2009
perchè devi mettere:
text1.text = text1.text & ( UCase(drive))
magari mettile separate da uno spazio:
text1.text = text1.text & " " & ( UCase(drive))

PM Quote
Avatar
swet (Normal User)
Pro


Messaggi: 128
Iscritto: 01/01/2009

Segnala al moderatore
Postato alle 16:54
Giovedì, 01/01/2009
grazie funzionaaaaaa!!!!!! stavo fondendo e invece era semplicissimo!!!grazie!!

PM Quote