Dim m, n As Integer
Dim i, x As Integer
m = Val(Text1.Text)
n = Val(Text2.Text)
i = 1
a = m
b = n
If n * m = 0 Then
MsgBox "兩數任何壹個數都不能為0!"
Exit Sub
End If
For x = 2 To n Step 1
If m Mod x = 0 And n Mod x = 0 Then
Do While a Mod x = 0 And b Mod x = 0
i = x * i
a = a / x
b = b / x
Loop
End If
Next x
Label6.Caption = i * a * b
Label5.Caption = i
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Label5.Caption = ""
Label6.Caption = ""
End Sub
Private Sub Form_Load()
Command1.Caption = "計算"
Command2.Caption = "清除"
Text1.Text = ""
Text2.Text = ""
Label5.Caption = ""
Label6.Caption = ""
End Sub