1.11M Members

Check Decimal Places

 
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.

 
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
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article