r没有初值,程序开始后
Do Until r = 0
m1 = n1
n1 = r
r = m1 - n1
Loop
这一段没什么用。。。直接就r=0了
unction zdgys(ByVal m As Long, ByVal n As Long) As Long '最大公约数
Dim min As Long, i As Long
min = IIf(m >= n, n, m)
zdgys = 1
For i = 1 To min
If m Mod i = 0 And n Mod i = 0 Then zdgys = i
Next
End Function
Function zxgbs(ByVal m As Long, ByVal n As Long) As Long '最小公倍数
Dim max As Long, i As Long
max = IIf(m >= n, m, n)
zxgbs = max
For i = m * n To max Step -1
If i Mod m = 0 And i Mod n = 0 Then zxgbs = i
Next
End Function
这个或许好一些