Lumart Lumart - 1 year ago 81 Question

Decimal places in a number on

How do I check how many decimal places does a number have in

For example: Inside a loop I have an if statement and on that statement I want to check if a number has 4 decimal places (8.9659)

Answer Source
Dim numberAsString As String = myNumber.ToString()
Dim indexOfDecimalPoint As Integer = numberAsString.IndexOf(".")
Dim numberOfDecimals As Integer = _
    numberAsString.Substring(indexOfDecimalPoint + 1).Length
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download