S
Steve
I am using Label1 = 15 and Label2 = 18. When I run the procedure I get a
value of 0. I should get 3. I can't figure out what is going wrong.
Sub gcd()
Dim tmp As Long
Dim remainder As Long
Dim a As Integer
Dim b As Integer
Dim c As Integer
' Make a >= b.
a = Label1.Text
b = Label2.Text
If a < b Then
tmp = a
a = b
b = tmp
End If
' Pull out remainders.
Do Until remainder = 0
remainder = a Mod b
If remainder = 0 Then
c = b
Else
a = b
b = remainder
End If
Loop
End Sub
Thanks for any help.
value of 0. I should get 3. I can't figure out what is going wrong.
Sub gcd()
Dim tmp As Long
Dim remainder As Long
Dim a As Integer
Dim b As Integer
Dim c As Integer
' Make a >= b.
a = Label1.Text
b = Label2.Text
If a < b Then
tmp = a
a = b
b = tmp
End If
' Pull out remainders.
Do Until remainder = 0
remainder = a Mod b
If remainder = 0 Then
c = b
Else
a = b
b = remainder
End If
Loop
End Sub
Thanks for any help.