當前位置:編程學習大全網 - 編程軟體 - vb 求兩個數最小公倍數最小公倍數

vb 求兩個數最小公倍數最小公倍數

Private Sub Command1_Click()

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

  • 上一篇:數學微課如何制作
  • 下一篇:點燃我溫暖妳電視劇在哪裏看
  • copyright 2024編程學習大全網