```
Sub Round2(Number As Double,DecimalPlaces As Int) As Double
Dim NaObj As NativeObject
NaObj = NaObj.Initialize("NSNumber").RunMethod("numberWithDouble:",Array(Number))
Dim strNumber As String = NaObj.GetField("stringValue").AsString
Dim DotIndex As Int = strNumber.IndexOf(".")
Dim NumberOfDecimalPlaces As Int = strNumber.Length - DotIndex -1
If DecimalPlaces >= NumberOfDecimalPlaces Then
Return Number
End If
If Not(DecimalPlaces = 0) Then
Dim LastNumber As Int = strNumber.SubString2(DotIndex + DecimalPlaces,DotIndex + DecimalPlaces+1)
Else
Dim LastNumber As Int = strNumber.SubString2(DotIndex + DecimalPlaces -1,DotIndex + DecimalPlaces)
End If
Dim NumberBefore As Int = strNumber.SubString2(DotIndex + DecimalPlaces +1,DotIndex + DecimalPlaces+2)
If NumberBefore > 4 Then
LastNumber = LastNumber +1
End If
If Not(DecimalPlaces = 0) Then
Dim RoundedNumber As Double = strNumber.SubString2(0,DotIndex + DecimalPlaces) & LastNumber
Else
Dim RoundedNumber As Double = strNumber.SubString2(0,DotIndex + DecimalPlaces -1) & LastNumber
End If
Return RoundedNumber
End Sub
```