展开全部
Dim m As Integer, n As Integer
Private Sub Command1_Click()
m = Val(InputBox("输入正整数"))
n = Val(InputBox("输入正整数"))
If n * m = 0 Then
MsgBox "两数任何一个数都不能为0!"
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Dim r As Integer, s As Integer
r = m: s = 1
Do Until m Mod r = 0 And n Mod r = 0 '最大公约数
r = r - 1
Loop
Do Until s Mod m = 0 And s Mod n = 0 '最小公倍数
s = s + 1
Loop
Text1.Text = "最大公约数是:" & r & "最小公倍数是:" & s
End Sub
Private Sub Command1_Click()
m = Val(InputBox("输入正整数"))
n = Val(InputBox("输入正整数"))
If n * m = 0 Then
MsgBox "两数任何一个数都不能为0!"
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Dim r As Integer, s As Integer
r = m: s = 1
Do Until m Mod r = 0 And n Mod r = 0 '最大公约数
r = r - 1
Loop
Do Until s Mod m = 0 And s Mod n = 0 '最小公倍数
s = s + 1
Loop
Text1.Text = "最大公约数是:" & r & "最小公倍数是:" & s
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询