Please, for your own health, turn Option Strict
and Option Explicit
on, stop using the return variable unless you really want to, and drop the legacy VB6 functions (like Int
).
Then you can probably hack something together with a string format like this:
Public Function Rounded(number As Decimal, decimals As Integer) As String
Return number.ToString("0." & New String("0"c, decimals))
End Function
Itβs generally better to just use the format string yourself if you can, though, as in num.ToString("0.000")
for three decimal places, and drop Rounded
entirely.