Utilisateur anonyme
-
16 nov. 2006 à 14:53
le pro masterchief
Messages postés57Date d'inscriptionvendredi 4 novembre 2005StatutMembreDernière intervention 9 avril 2008
-
17 nov. 2006 à 01:56
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
Ha oui bien vu DTHULER!
Ces solutions fonctionnes, mais la sienne j'arrive pas à la faire marcher et toi?
cs_Willi
Messages postés2375Date d'inscriptionjeudi 12 juillet 2001StatutModérateurDernière intervention15 décembre 201822 16 nov. 2006 à 17:03
>Et j'ai une question a vous les admin jvoudrai savoir pourquoi vous avez enleverz mon code?
Pour connaitre la raison, regarde tes MP sur Codes-Sources.
dthuler
Messages postés121Date d'inscriptiondimanche 9 mars 2003StatutMembreDernière intervention29 avril 2009 16 nov. 2006 à 17:03
Salut, l'attention est bonne mais sa existait déjà: (certe pas sur ce site, en tout cas j'ai pas cherché), mais bonne initiative comme même! sauf que j'ai mis ça dans VBA et ça marche pas!
Private Sub CommandButton1_Click()
Call findfile("C:\Classeur1.xls")
End Sub
Public Function findfile(nomcomplet As String) As String
For o = Len(nomcomplet) To 1 Step -1
If Mid(nomcomplet, o, 1) = "" Then
findfile = Right(nomcomplet, Len(nomcomplet) - o)
Exit For
Else
findfile = "erreur"
End If
Next o
MsgBox (finfile)
Public Function ExtractFileExt(ByVal sFullPath As String) As String
Dim sName As String
sName = ExtractFileName(sFullPath)
If InStr(sName, ".") = 0 Then
ExtractFileExt = ""
Else
ExtractFileExt = Mid(sName, InStrRev(sName, ".") + 1)
End If
End Function
17 nov. 2006 à 01:56
16 nov. 2006 à 20:15
16 nov. 2006 à 17:54
16 nov. 2006 à 17:21
Ces solutions fonctionnes, mais la sienne j'arrive pas à la faire marcher et toi?
16 nov. 2006 à 17:03
Pour connaitre la raison, regarde tes MP sur Codes-Sources.
16 nov. 2006 à 17:03
Encore plus court:
nomdefichier = right(chemincomplet,len(chemincomplet)-instrrev(chemincomplet,""))
Quelqu'un d'autre ? ;-)
David
16 nov. 2006 à 16:51
16 nov. 2006 à 16:24
Public Function Nomfichier(ByVal nomcomplet As String) As String
If My.Computer.FileSystem.FileExists(nomcomplet) = True Then
Dim SplitChemin() As String
SplitChemin = Split(nomcomplet, "", -1, vbTextCompare)
Nomfichier = SplitChemin(SplitChemin.Length - 1)
Return Nomfichier
Else
Return MsgBox("Le fichier n'existe pas")
End If
End Function
'Exemple d'utilisation
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call Nomfichier("C:\Classeur1.xls")
End Sub
16 nov. 2006 à 16:23
Private Sub CommandButton1_Click()
Call Nomfichier("C:\Classeur1.xls")
End Sub
Public Function Nomfichier(nomcomplet As String) As String
Dim SplitChemin() As String
SplitChemin = Split(nomcomplet, "", -1, vbTextCompare)
Nomfichier = SplitChemin(UBound(SplitChemin))
MsgBox (Nomfichier)
End if
End Function
16 nov. 2006 à 14:59
Call Nomfichier("C:\Classeur1.xls")
End Sub
Public Function Nomfichier(nomcomplet As String) As String
Autre façon de faire qui fonctionne en VBA et VB6:
Dim SplitChemin() As String
Dim i As Integer
SplitChemin = Split(nomcomplet, "", -1, vbTextCompare)
Nomfichier = SplitChemin(UBound(SplitChemin))
MsgBox (Nomfichier)
End Function
16 nov. 2006 à 14:53
Private Sub CommandButton1_Click()
Call findfile("C:\Classeur1.xls")
End Sub
Public Function findfile(nomcomplet As String) As String
For o = Len(nomcomplet) To 1 Step -1
If Mid(nomcomplet, o, 1) = "" Then
findfile = Right(nomcomplet, Len(nomcomplet) - o)
Exit For
Else
findfile = "erreur"
End If
Next o
MsgBox (finfile)
End Function
http://vb.developpez.com/faq/?page=Fichiers#ext_rep
Public Function ExtractFileExt(ByVal sFullPath As String) As String
Dim sName As String
sName = ExtractFileName(sFullPath)
If InStr(sName, ".") = 0 Then
ExtractFileExt = ""
Else
ExtractFileExt = Mid(sName, InStrRev(sName, ".") + 1)
End If
End Function