Start New Discussion within our Software Development Community

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)
            txtPlaces = CStr(lngPlace)
        End If
    Else ' Clear out text boxes
        txtDecimal = vbNullString
        txtPlaces = vbNullString
        Exit Sub
    End If
End Sub
This article has been dead for over six months. Start a new discussion instead.