loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lindafay1123
    New Member
    • Dec 2009
    • 3

    loop

    I am having trouble with a problem. I started a problem in basic add a button and text box and below is the code I use but when i hit the button it doesn't give me anything and it should give me 2.
    Public Class Form1

    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

    End Sub
    Private Sub btnDisplay_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s)
    'Calculate the remainder in long division
    txtOutput.Text = CStr(Remainder( 3, 17))
    End Sub
    Function Remainder(ByVal divisor As Double, _
    ByVal dividend As Double) As Double
    Dim sum As Double = 0
    Do While (dividend - sum) >= divisor
    sum += divisor
    Loop
    Return (dividend - sum)

    End Function
    End Class
    What am I missing?
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    dear,


    can you explain what the loop just must do?
    because :
    - "sum += divisor" is not correct in vb.
    - return is for a GOSUB => the functionname is returning the value !

    Comment

    • Guido Geurs
      Recognized Expert Contributor
      • Oct 2009
      • 767

      #3
      dear,


      can you explain what the loop just must do?
      because :
      - "sum += divisor" is not correct in vb.
      - "return" is for a GOSUB => the functionname is returning the value !
      it must be "Remainder=.... .."

      I hope i can help You furder once these problems are cleard.

      br,

      Comment

      • lindafay1123
        New Member
        • Dec 2009
        • 3

        #4
        it is supposed to output the remainder

        Comment

        • vb5prgrmr
          Recognized Expert Contributor
          • Oct 2009
          • 305

          #5
          Please have a look at the Mod Function and in the future please do not post .net questions in the visual basic classic section that covers version 4/5/6

          .net covers 2002, 2003, 2005, 2008, and soon 2010 versions of vb, c#, asp...



          Good Luck

          Comment

          Working...