ASP - val function

Asked By anita kamat on 16-Apr-10 06:30 PM
I need to use a fucntion in asp that is equal to the val function in visual basic. any suggestion will do.
Venkat K replied to anita kamat on 16-Apr-10 09:36 PM
to get the functionality of Val() - return a numeric value from a string until the first non-numeric character, you have to write your own function. Here internally i am using Binary algorithm to implement the logic. You can directly used this function in asp.

Function Val(ByVal s)
    Dim i, sTemp, iTemp
    iTemp = 0
    For i = 0 To Len(s)
        sTemp = Mid(s,1,i)
        If IsNumeric(sTemp) Then
            iTemp = Clng(sTemp)
        Else
            Val = iTemp
            Exit Function
        End If
    Next
End Function

Thanks
Santhosh N replied to anita kamat on 17-Apr-10 12:51 AM
You can make use of Cint in asp which converts the string to integer type if that is your requirement
anita kamat replied to Venkat K on 17-Apr-10 10:33 PM
thanks Venkat