Get the remainder without using mod function in vb.net

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #3731

    Hi
    You can get the remainder of the two values without using mod function with the help of the following example:

    [code title=””] Private Function nMod(ByVal X As Double, _
    ByVal Y As Double) As Double
    Dim dblValue As Double = 0
    dblValue = (X – (Int(X / Y) * Y))
    nMod = dblValue
    End Function[/code]

    Now see the result of the following expression:
    [code title=””]
    Dim Rem1 As Double = nMod(52.5, 2)
    Dim Rem2 As Double = 52.5 Mod 2[/code]

    The value of the Rem1 and Rem2 would be same..

    Enjoy Programming

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.