RicH and FamouS

       Home         Glosar IT                                                                                                                                                                                                              SUBSCRIBE NOW!
        

07.04.2009

Alte functii utile in ASP

Functie de eliminat tagurile HTML dintr-un text, bazat pe expresii regulare:

Cod:
Function RemoveHTML( strText )
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
RemoveHTML = RegEx.Replace(strText & "", "")
End Function

O functie de afisat numerele cu 2 zecimale sau fara nici o zecimala daca sint intregi. De exemplu va afisa 2.34 sau doar 2 pentru 2.00:

Cod:
function FormatNumber2(x)
if x-int(x)=0 then
FormatNumber2=FormatNumber(x,0)
else
FormatNumber2=FormatNumber(x,2)
end if
end function

Functie de extras extensia unui fisier:

Cod:
Function GetExt(FileName)
Dim start
start=InstrRev(FileName,".")
GetExt=Mid(FileName,start+1)
End Function

Verificat daca un fisier exista:

Cod:
Function FileExist(FileName)
path=Server.MapPath("folder/" & FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
FileExist=fso.FileExists(path)
Set fso = Nothing
End Function

Sters un fisier:

Cod:
Function DeleteFile(FileName)
path=Server.MapPath("folder/" & FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(path)
Set fso = Nothing
End Function

    Blog din Moldova    FastCounter 

 
Copyright © 2008-2010 Foster1. All rights reserved.