mod function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    mod function

    I am trying to get label2 to divided enely into label1. Numbers are being
    randomly placed into label1 and label2. I have written the following
    procedure but the numbers that are being placed in the label boxes are not
    dividing evenly. Below is my code. Any help is appreciated.

    Sub fillnumdiv()

    'Needed to make Do While Loop work

    lblNum1.Text = 3

    lblNum2.Text = 2

    'Make sure the top number is greater than the bottom number.

    Do

    'Checks all of the conditions for the number to be placed in the label box
    for the first number.

    If CheckBox2.Check ed Then

    Randomize()

    lblNum1.Text = CInt(Int((TextB ox2.Text * Rnd())))

    ElseIf CheckBox1.Check ed Then

    Randomize()

    lblNum1.Text = TextBox1.Text

    Else

    Randomize()

    lblNum1.Text = CInt(Int((145 * Rnd())))

    End If

    ' Checks all of the conditions for the number to be placed in the label box
    for the second number.

    If CheckBox3.Check ed Then

    Randomize()

    lblNum2.Text = CInt(Int((TextB ox3.Text * Rnd())))

    ElseIf CheckBox4.Check ed Then

    Randomize()

    lblNum2.Text = TextBox4.Text

    Else

    Randomize()

    lblNum2.Text = CInt(Int((145 * Rnd())))

    End If

    Loop Until CDec(Int(lblNum 1.Text) Mod Int(lblNum2.Tex t)) = 0 And
    Int(lblNum2.Tex t) <> 0

    End Sub


Working...