1、1、最大公约数 2、最小公倍数 Private Sub Command1_Click() Private Sub Command1_Click()Dim a As Long Dim a As LongDim b As Long Dim b As LongDim c As Long Dim c As Longa = Val(Text1.Text) Dim d As Longb = Val(Text2.Text) a = Val(Text1.Text)Do b = Val(Text2.Text)c = a Mod b x = aa = b y = bb = c DoLoop Until c = 0
2、 c = a Mod b Text3.Text = a a = bEnd Sub b = cPrivate Sub Command2_Click() Loop Until c = 0Text1.Text = “ d = a Text2.Text = “ Text3.Text = d * (x / d) * (y / d)Text3.Text = “ End Sub Text1.SetFocus Private Sub Command2_Click() 同 1 略 End Sub Private Sub Command3_Click() 同 1 略Private Sub Command3_Cli
3、ck()EndEnd Sub3、阶乘 4、因数Private Sub Command1_Click() Private Sub Command1_Click()Dim a As Long, i As Integer, s As Integer Dim x As Integer, k As Integera = Val(Text1.Text) Dim s As Strings = 1 k = 2i = 1 x = Val(Text1.Text)If a 0 Then Else: k = k + 1For i = 1 To a End Ifs = s * I Loop Until x = 1Nex
4、t i List1.AddItem Text1.Text &Text2.Text = s “=“ & Left(s, Len(s) - 1)End If End Sub5、质数 6、逆序Private Sub Command1_Click() Private Sub Command1_Click()Dim N As Long Dim s As String, a As StringN = Val(Text1.Text) Dim i As IntegerFor i = 2 To Sqr(N) s = Text1.TextIf N Mod i = 0 Then For i = 1 To Len(s)Text2.Text = “no“ a = Mid(s, i, 1) & aExit For Next iElse: Text2.Text = “yes“ Text2.Text = aEnd If End SubNextEnd SubPrivate Sub Command2_Click()同 1 略Private Sub Command3_Click()同 1 略