begin process at 2008 08 22 03:46:07
1 229 771 membres
42 nouveaux aujourd'hui
14 267 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

TROUVER LE NOM LONG À PARTIR DU NOM MS-DOS 8.3


Information sur la source

Catégorie :Fichier / Disque Classé sous : nom, msdos, dos Niveau : Expert Date de création : 05/08/2001 Vu : 1 832

Note :
5,5 / 10 - par 4 personnes
5,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

Description

Copiez le code dans un .BAS et exécuter la fonction comme ceci:
nom_long=trouve_le_nom_long("C:\PROGRA~1\YES.EXE")

Vous avez besoin d'un dirlistbox appelé dir1,d'une listbox appelée liste et d'un filelistbox appelé file1
Voilà, en espèrant que ce code va en aider plus d'un...

Source

  • Public Function trouve_le_nom_long(file As String) As String
  • Dir1.Path = "\"
  • chemin = "\"
  • position = 4
  • Do
  • a = InStr(position + 1, file, "\")
  • If a = 0 Then GoTo fin
  • dossier = Mid(file, position, a - position)
  • If InStr(1, dossier, "~") <> 0 Then
  • If chemin <> "\" Then
  • If Right(Dir1.Path, 1) = "\" Then
  • nom = Dir1.Path
  • Else: nom = Dir1.Path & "\"
  • End If
  • position = Len(nom) + 1
  • End If
  • For i = 0 To Dir1.ListCount - 1
  • If Left(dossier, InStr(1, dossier, "~") - 1) = UCase(Mid(Dir1.List(i), position, Len(Left(dossier, InStr(1, dossier, "~") - 1)))) And Len(Mid(Dir1.List(i), position)) > 8 Then
  • incr = Len(Dir1.List(i)) + 1
  • Do
  • incr = incr - 1
  • Loop Until Mid(Dir1.List(i), incr, 1) = "\"
  • zaza = Right(Dir1.List(i), Len(Dir1.List(i)) - incr)
  • Liste.AddItem (zaza)
  • End If
  • Next
  • chemin = chemin & Liste.List(Right(dossier, 1) - 1) & "\"
  • Liste.Clear
  • Else
  • For i = 0 To Dir1.ListCount - 1
  • If UCase(Right(Dir1.List(i), Len(dossier))) = dossier Then dossier = Right(Dir1.List(i), Len(dossier))
  • Next
  • chemin = chemin & dossier & "\"
  • End If
  • Dir1.Path = chemin
  • position = a + 1
  • Loop
  • fin:
  • trouve_le_nom_long = Dir1.Path
  • namen = trouve_le_nom_du_fichier(file, Dir1.Path)
  • If Right(trouve_le_nom_long, 1) = "\" Then
  • trouve_le_nom_long = trouve_le_nom_long & namen
  • Else: trouve_le_nom_long = trouve_le_nom_long & "\" & namen
  • End If
  • End Function
  • Public Function trouve_le_nom_du_fichier(abc As String, chemin_initial As String) As String
  • Liste.Clear
  • File1.Path = chemin_initial
  • incr = Len(abc) + 1
  • Do
  • incr = incr - 1
  • Loop Until Mid(abc, incr, 1) = "\"
  • nom = Mid(abc, incr + 1)
  • a = InStr(1, nom, "~")
  • If a = 0 Then
  • For i = 0 To File1.ListCount - 1
  • If UCase(File1.List(i)) = nom Then
  • trouve_le_nom_du_fichier = File1.List(i)
  • End If
  • Next
  • GoTo fin
  • Else
  • For i = 0 To File1.ListCount - 1
  • If Left(nom, 6) = UCase(Mid(File1.List(i), 1, Len(Left(nom, 6)))) Then
  • Liste.AddItem (File1.List(i))
  • End If
  • Next
  • trouve_le_nom_du_fichier = Liste.List(Val(Mid(nom, InStr(1, nom, "~") + 1)) - 1)
  • End If
  • fin:
  • End Function
Public Function trouve_le_nom_long(file As String) As String

Dir1.Path = "\"
chemin = "\"
position = 4
Do
a = InStr(position + 1, file, "\")
If a = 0 Then GoTo fin

dossier = Mid(file, position, a - position)


If InStr(1, dossier, "~") <> 0 Then

If chemin <> "\" Then

    If Right(Dir1.Path, 1) = "\" Then
    nom = Dir1.Path
    Else: nom = Dir1.Path & "\"
    
End If

position = Len(nom) + 1

End If




For i = 0 To Dir1.ListCount - 1
If Left(dossier, InStr(1, dossier, "~") - 1) = UCase(Mid(Dir1.List(i), position, Len(Left(dossier, InStr(1, dossier, "~") - 1)))) And Len(Mid(Dir1.List(i), position)) > 8 Then


incr = Len(Dir1.List(i)) + 1
Do
incr = incr - 1
Loop Until Mid(Dir1.List(i), incr, 1) = "\"

zaza = Right(Dir1.List(i), Len(Dir1.List(i)) - incr)



Liste.AddItem (zaza)
End If

Next

chemin = chemin & Liste.List(Right(dossier, 1) - 1) & "\"
Liste.Clear


Else


For i = 0 To Dir1.ListCount - 1
If UCase(Right(Dir1.List(i), Len(dossier))) = dossier Then dossier = Right(Dir1.List(i), Len(dossier))
Next

chemin = chemin & dossier & "\"

End If

Dir1.Path = chemin

position = a + 1



Loop


fin:
trouve_le_nom_long = Dir1.Path
namen = trouve_le_nom_du_fichier(file, Dir1.Path)
If Right(trouve_le_nom_long, 1) = "\" Then
trouve_le_nom_long = trouve_le_nom_long & namen
Else: trouve_le_nom_long = trouve_le_nom_long & "\" & namen
End If




End Function






Public Function trouve_le_nom_du_fichier(abc As String, chemin_initial As String) As String

Liste.Clear


File1.Path = chemin_initial

incr = Len(abc) + 1
Do
incr = incr - 1
Loop Until Mid(abc, incr, 1) = "\"

nom = Mid(abc, incr + 1)


a = InStr(1, nom, "~")
If a = 0 Then

For i = 0 To File1.ListCount - 1
If UCase(File1.List(i)) = nom Then
trouve_le_nom_du_fichier = File1.List(i)
End If
Next

GoTo fin

Else



For i = 0 To File1.ListCount - 1
If Left(nom, 6) = UCase(Mid(File1.List(i), 1, Len(Left(nom, 6)))) Then

Liste.AddItem (File1.List(i))
End If

Next

trouve_le_nom_du_fichier = Liste.List(Val(Mid(nom, InStr(1, nom, "~") + 1)) - 1)



End If


fin:

End Function
 
  • signaler à un administrateur
    Commentaire de florantanplan le 26/04/2004 16:13:38

    Déclarer les variables, tu connais!!!

Ajouter un commentaire

Pub



Appels d'offres

CalendriCode

Août 2008
LMMJVSD
    123
45678910
11121314151617
18192021222324
25262728293031

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Téléchargements

Boutique

Boutique de goodies CodeS-SourceS