'''''''''''''''''''''''''''''''''''''''''''''''''''''
' Extraction nom du fichier à partir d'une variable
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'exemple1 : Fonction InStrRev
Dim CheminComplet_1, Position
CheminComplet_1 = "C:\Exemples\Exemple_1.txt"
Position = ""
'
'Renvoie la position de la première occurence d'une chaîne dans une autre,
'à partir de la fin de la chaîne. . Dans cet exemple: ""
Position = InStrRev(CheminComplet_1,"")
Position = Mid(CheminComplet_1, Position+1, Len(CheminComplet_1))
MsgBox "Exemple1 : Fonction InStrRev => " & Position
'
'exemple2 : Fonction For...Next
Dim CheminComplet_2, i, Fichier, Caractere
CheminComplet_2 = "C:\Exemples\Exemple_2.txt"
i = 0
'
'Répète un groupe d'instructions un nombre spécifié de fois. Dans cet exemple: ""
For i = Len(CheminComplet_2) To 1 Step -1
Caractere = Mid(CheminComplet_2, i, 1)
If Caractere = "" Then Exit For
Fichier = Caractere & Fichier
MsgBox "Exemple2 : Fonction For...Next => " &vbCrLf&"caractère courant = " &_
Caractere &vbCrLf & "caractère + fichier = " & Fichier
Next
'
'
MsgBox "Exemple1 : Fonction InStrRev => " & Position &vbCrLf&_
"Exemple2 : Fonction For...Next => " & Fichier