View Full Version : [VB] etrarre solo il nome del file senza estensione
MisterW2
30-04-2002, 20:02
Forse per voi domanda facile....
Tramite un settaggio su un text va una cosa del tipo:
c:\windows\nomefile.txt
voglio che venga estratto solo nomefile.
Mi sapreste dire come?
Grazie mille.
Una funzione buttata gił in fretta:
Public Function GetFileName(pathname As String) As String
Dim p1 As Integer
Dim p2 As Integer
Dim temp As String
'toglie path
Do
p1 = p2
p2 = InStr(p1 + 1, pathname, "\")
Loop Until p2 = 0
temp = Right$(pathname, Len(pathname) - p1)
'toglie estensione
p1 = InStr(temp, ".")
If p1 > 0 Then temp = Left$(temp, p1 - 1)
GetFileName = temp
End Function
ciao
MisterW2
30-04-2002, 23:16
Grazie per l'aiuto
solonome=left(nomecompleto,instr(nomecompleto,".")-1)
Bye !!
Originariamente inviato da beee
[B]solonome=left(nomecompleto,instr(nomecompleto,".")-1)
Con un file che si chiama pippo.pluto.txt non funziona ;)
MisterW2
01-05-2002, 23:59
Beh forse, ma ringrazio uguale, a me basta per file con una sola estensione... poi per togliere la path basta che gli passo il fileTitle..
Grazie atutti...
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.