Private Function GetMinNum(m As Integer, n As Integer) As Integer
Dim tm As Integer, tn As Integer, t As Integer
tm = m
tn = n
If tm <= 0 Or tn <= 0 Then
GetMinNum = -1
Exit Function
End If
if tm < tn Then
t = tn
tn = tm
tm = t
End If
t = tm Mod tn
While t
tm = tn
tn = t
t = tm Mod tn
Wend
GetMinNum = m * n / tm
End Function
Private Sub Command1_Click()
Dim m As Integer
Dim n As Integer
Dim min As Integer
m = Int(InputBox("请输入
正整数m"))
n = Int(InputBox("请输入正整数n"))
min = GetMinNum(m, n)
If min > 0 Then
MsgBox "2数的
最小公倍数为:" & min
Else
MsgBox "输入的整数不符要求!"
End If
End Sub