Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim m As Integer, n As Integer
        Dim m1 As Integer, n1 As Integer
        Dim r As Integer, t As Integer
        m = InputBox("请输入第一个数")
        n = InputBox("请输入第二个数")
        m1 = m : n1 = n    '保存原始数据供输出使用
        If m < n Then
            t = m : m = n : n = t
        End If
        Do
            r = m Mod n
            m = n : n = r
        Loop Until (r = 0)
        MsgBox(Str(m1) + "和" + Str(n1) + "的最大公约数是" + Str(m))
    End Sub
End Class
