Retorna o nome de arquivo em um caminho.
Function GetFileName(ByVal Path)
Path = Replace(Path, "/", "\")
GetFileName = Right(Path, Len(Path) - InStrRev(Path, "\"))
End Function
Este blog é originalmente para ser um banco de funções e procedimentos públicas de qualquer linguagem, como a minha especialidade é liguagens Microsoft® vou me ater a elas, mas caso haja pessoas interessadas em passar funções ou procedimentos de outras linguagens, sintam-se a vontade para envia-las a mim.
quinta-feira, 29 de novembro de 2007
segunda-feira, 26 de novembro de 2007
GetFileExt()
Retorna a extensão do arquivo em um caminho.
Function GetFileExt(ByVal p)
GetFileExt = Right(p, Len(p) - InStrRev(p, "."))
End Function
Function GetFileExt(ByVal p)
GetFileExt = Right(p, Len(p) - InStrRev(p, "."))
End Function
sexta-feira, 23 de novembro de 2007
GetFile()
Obtém um arquivo e retorna um objeto File.
O FileName pode ser um caminho absoluto ou relativo.
Function GetFile(ByVal FileName)
On Error Resume Next
If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
If Err Then Err.Clear
On Error GoTo 0
Dim FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set GetFile = FSO.GetFile(FileName)
If Err Then
Err.Clear
Set GetFile = Nothing
End If
On Error GoTo 0
Set FSO = Nothing
End Function
O FileName pode ser um caminho absoluto ou relativo.
Function GetFile(ByVal FileName)
On Error Resume Next
If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
If Err Then Err.Clear
On Error GoTo 0
Dim FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set GetFile = FSO.GetFile(FileName)
If Err Then
Err.Clear
Set GetFile = Nothing
End If
On Error GoTo 0
Set FSO = Nothing
End Function
quinta-feira, 22 de novembro de 2007
FolderExists()
Checa se uma pasta existe.
O DirName pode ser um caminho absoluto ou relativo.
Function FolderExists(ByVal DirName)
On Error Resume Next
If Mid(DirName, 2, 1) <> ":" Then
DirName = Server.MapPath(DirName)
End If
On Error GoTo 0
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
FolderExists = fso.FolderExists(DirName)
Set fso = Nothing
End Function
O DirName pode ser um caminho absoluto ou relativo.
Function FolderExists(ByVal DirName)
On Error Resume Next
If Mid(DirName, 2, 1) <> ":" Then
DirName = Server.MapPath(DirName)
End If
On Error GoTo 0
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
FolderExists = fso.FolderExists(DirName)
Set fso = Nothing
End Function
quarta-feira, 21 de novembro de 2007
FileExists()
Checa se um arquivo existe.
O FileName pode ser um caminho absoluto ou relativo.
Function FileExists(ByVal FileName)
On Error Resume Next
If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
On Error GoTo 0
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(FileName)
Set fso = Nothing
End Function
O FileName pode ser um caminho absoluto ou relativo.
Function FileExists(ByVal FileName)
On Error Resume Next
If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
On Error GoTo 0
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(FileName)
Set fso = Nothing
End Function
terça-feira, 20 de novembro de 2007
FileCountLines()
Conta o número de linhas em um arquivo.
Function FileCountLines(ByVal FileName)
Dim sStream
Dim iLines
Dim i, j, k
If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
sStream = ReadFile(FileName)
i = 1
j = 1
iLines = 0
k = Len(sStream)
Do While i <= k
i = InStr(i, sStream, vbCrLf)
If i = 0 Then Exit Do
iLines = iLines + 1
i = i + 2
Loop
If iLines > 0 Then iLines = iLines + 1
FileCountLines = iLines
End Function
Function FileCountLines(ByVal FileName)
Dim sStream
Dim iLines
Dim i, j, k
If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
sStream = ReadFile(FileName)
i = 1
j = 1
iLines = 0
k = Len(sStream)
Do While i <= k
i = InStr(i, sStream, vbCrLf)
If i = 0 Then Exit Do
iLines = iLines + 1
i = i + 2
Loop
If iLines > 0 Then iLines = iLines + 1
FileCountLines = iLines
End Function
segunda-feira, 19 de novembro de 2007
ereg_replace()
Substituição de expressão regular não sensível a caixa.
Function ereg_replace(ByVal Expr, ByVal Subs, ByVal Varn)
Dim Regex
Set Regex = New RegExp
Regex.Pattern = Expr
Regex.IgnoreCase = False
Regex.Global = True
ereg_replace = Regex.Replace(Varn, Subs)
Set Regex = Nothing
End Function
Function ereg_replace(ByVal Expr, ByVal Subs, ByVal Varn)
Dim Regex
Set Regex = New RegExp
Regex.Pattern = Expr
Regex.IgnoreCase = False
Regex.Global = True
ereg_replace = Regex.Replace(Varn, Subs)
Set Regex = Nothing
End Function
quarta-feira, 7 de novembro de 2007
eregi_replace()
Substituição por expressão regular sensível a caixa.
Function eregi_replace(ByVal Expr, ByVal Subs, ByVal Varn)
Dim Regex
Set Regex = New RegExp
Regex.Pattern = Expr
Regex.IgnoreCase = True
Regex.Global = True
eregi_replace = Regex.Replace(Varn, Subs)
Set Regex = Nothing
End Function
Function eregi_replace(ByVal Expr, ByVal Subs, ByVal Varn)
Dim Regex
Set Regex = New RegExp
Regex.Pattern = Expr
Regex.IgnoreCase = True
Regex.Global = True
eregi_replace = Regex.Replace(Varn, Subs)
Set Regex = Nothing
End Function
terça-feira, 6 de novembro de 2007
eregi()
Teste de expressão regular não sensível a caixa
Function eregi(ByVal Expr, ByVal Varn)
Dim Regex
Set Regex = New RegExp
Regex.Pattern = Expr
Regex.IgnoreCase = True
Regex.Global = True
eregi = Regex.Test(Varn)
Set Regex = Nothing
End Function
Function eregi(ByVal Expr, ByVal Varn)
Dim Regex
Set Regex = New RegExp
Regex.Pattern = Expr
Regex.IgnoreCase = True
Regex.Global = True
eregi = Regex.Test(Varn)
Set Regex = Nothing
End Function
quinta-feira, 1 de novembro de 2007
ereg()
Teste de expressão regular sensível a caixa.
Function ereg(ByVal Expr, ByVal Varn)
Dim Regex
Set Regex = New RegExp
Regex.Pattern = Expr
Regex.IgnoreCase = False
Regex.Global = True
ereg = Regex.Test(Varn)
Set Regex = Nothing
End Function
Function ereg(ByVal Expr, ByVal Varn)
Dim Regex
Set Regex = New RegExp
Regex.Pattern = Expr
Regex.IgnoreCase = False
Regex.Global = True
ereg = Regex.Test(Varn)
Set Regex = Nothing
End Function
Assinar:
Postagens (Atom)