1,105,534 Community Members

Check Decimal Places

Member Avatar
dark_enig
Newbie Poster
1 post since Mar 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
hkdani
Posting Pro in Training
433 posts since Nov 2007
Reputation Points: 39 [?]
Q&As Helped to Solve: 46 [?]
Skill Endorsements: 2 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article