LiveWire Peer Support Network

Printable Version of Topic "VB.net evenly divide checker"

- LiveWire Teen Forums & College Forums (http://www.golivewire.com)
-- (http://www.golivewire.com/forums/support-technical.html)
--- Programming & Application Development (http://www.golivewire.com/forums/forum-211-s-0.html)
---- VB.net evenly divide checker (http://www.golivewire.com/forums/peer-ttnien-support-a.html)


-- Posted by j3100 at 2:10 pm on Sep. 30, 2007

I'm trying to write a simple program that will check to see if a given number will divide evenly into a fixed number (no remainder).  For example I would enter a number and click a button called "check" and it would tell me yes or no weather it is evenly divided by the other number.  Does anybody know how I could do it in vb.net 2003??  I tried using an "If number = integer" but that didn't work.


-- Posted by ManicD at 2:13 pm on Sep. 30, 2007

what code have you so far?

(on LW use the [ code] type your text here [ /code] tags


-- Posted by vector3df at 6:36 pm on Sep. 30, 2007

Use the modulus operator.


-- Posted by j3100 at 6:57 pm on Sep. 30, 2007

cool. so I got it to to divide into that number, and if it does not divide into that number evenly, it would reduce the number so it does divide evenly:

       Dim ots As Long
       ots = tbOTS.Text
       If ots Mod 101 <> 0 Then
           tbOTS.Text = ots - (ots Mod 101)
       End If

I could now easily write another if statement to alert weather it divides evenly or not.  Thanks for the help Guys!


www.golivewire.com