Friday, May 1, 2009

Valid Float Number Function

 Public Function ValidFloatNumber(ByVal Ctrl As Object) As Boolean
        Dim Len, Arr, i
        Ctrl.text = Ctrl.text.trim
        Len = Ctrl.text.length
        Arr = Ctrl.text
        If Ctrl.text <> "" Then
            For i = 0 To Len - 1 Step 1
                If Not (((Asc(Arr(i)) >= 48 And Asc(Arr(i)) <= 57))) Then
                    If Not (Asc(Arr(i)) = 13) Then
                        If Not (Asc(Arr(i)) = 46) Then
                            MsgBox("Enter Only Digits ")
                            Ctrl.focus()
                            Return False
                        End If
                    End If
                End If
            Next
            If Len = 1 And Asc(Arr(0)) = 46 Then
                Ctrl.text = "0"
            End If
            If Not IsNumeric(Ctrl.text) Then
                MsgBox("Invalid Figure")
                Ctrl.focus()
                Return False
            End If
        End If
        Return True
  End Function


No comments:

Post a Comment