0

Hi Im new at VB Programming and I am in the middle of a project. I was wondering if there is a function or some other way of checking the number of decimal places a number has.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by hkdani
0
Private Sub cmdString_Click()
    Dim lngPlace As Long
    Dim strText As String
    
    If IsNumeric(txtDecimal) Then
        strText = txtDecimal
        ' Search for position of Decimal point
        lngPlace = InStr(1, strText, ".", vbTextCompare)
        txtPlaces = vbNullString
        If lngPlace > 0 Then
            txtPlaces = CStr(Len(strText) - lngPlace)
        Else
            txtPlaces = CStr(lngPlace)
        End If
    Else ' Clear out text boxes
        txtDecimal = vbNullString
        txtPlaces = vbNullString
        Exit Sub
    End If
End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.