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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.