Feedback

Nachkommastellen Wert erfahren

Sprache: VB

Gibt den Wert zurück nach ohne ganze Zahlen ist.
Public Function GetDecimals(ByVal V As Single) As Single
                Dim i As Integer = Global.System.Math.Truncate(V)
                Return V - i
            End Function

            Public Function GetDecimals(ByVal V As Double) As Double
                Dim i As Integer = Global.System.Math.Truncate(V)
                Return V - i
            End Function
Public Function GetDecimals(ByVal V As Single) As Single
                Dim i As Integer = Global.System.Math.Truncate(V)
                Return V - i
            End Function

            Public Function GetDecimals(ByVal V As Double) As Double
                Dim i As Integer = Global.System.Math.Truncate(V)
                Return V - i
            End Function

1 Kommentar

  1. Man kann das eigentlich noch kürzer schreiben. Wozu die Variable I definieren?

    [code]
    Public Function GetDecimals(ByVal V As Double) As Double
    Return V – Global.System.Math.Truncate(V)
    End Function
    [/code]