Página 1 de 1

Function GetExtension for Binders [VB6]

Publicado: 08 Ene 2010, 15:26
por The Swash

Código: Seleccionar todo

'---------------------------------------
'Coded by The Swash at 08/01/2010, thx DARK_J4V13R for generate personal idea
'[email protected]
'www.Indetectables.net
'---------------------------------------
Option Explicit

Public Function Getextension(spath As String) As String
 
 Dim extension  As String
 Dim x          As Integer
 
 If Len(spath) = 0 Then Exit Function
  If InStrRev(spath, ".") < InStrRev(spath, "\") Then Exit Function
   
   x = InStrRev(spath, ".")
    extension = Right$(spath, Len(spath) - x + 1)
    
    If extension = vbNullString Then Exit Function
  Getextension = extension
End Function
Use:
x = Getextension("C:\Indetectables.txt")
x = ".txt"

Full tested!

Re: Function GetExtension for Binders [VB6]

Publicado: 08 Ene 2010, 16:21
por irux
bueno de esto hablamos en el msn y pues te dije que hay otra forma tambien xD te lo mostrare

public function obtenerextencion(spath as string) as string



dim info() as string,info2() as string

dim info() = split(spath,"\")

if instr(1,info(ubound(info),"." then
' si tiene el punto entonces
info2() = split(ubound(info),".")
obtenerextencion= "." & info2(1)
else
'si no tiene extencion como me decias
obtenerextencion = info(ubound(info)
end if