quinta-feira, 14 de maio de 2009

AddChr

A função AddChr é usada para adicionar caráteres a uma string. Há três argumentos requeridos: Entrada, adição, posição.

<%
' Dim a
' a = "Help Me! Trapped in computer"
' Response.Write AddChr(a, ", can't get out", Len(a)) & "
"
' returns: "Help Me! Trapped in computer, can't get out"

Private Function AddChr(byVal string, byVal addition, byVal location)
Dim leftString, rightString

On Error Resume Next

leftString = Left(string, location)

If Err Then
leftString = ""
location = 0
End If

rightString = Mid(string, location + 1)

AddChr = leftString & addition & rightString

On Error GoTo 0
End Function

%>

sexta-feira, 27 de março de 2009

Verifica se a variável passada é um número

<%
' -> IsNaN 'Verifica se a variável passada é um número
Function IsNaN(ByVal n)
Dim d

On Error Resume Next
If Not isnumeric(n) Then
IsNan = true
Exit Function
End If
d = cdbl(n)
If err.number <> 0 then isNan = true else isNan = false
On Error GoTo 0
End Function
%>