...Option ExplicitPrivate
编辑: admin 2017-12-03
-
Option Explicit
Private Function Judge(n As Integer) AsBoolean
Dim i As Integer
For i = 2 To n-1
If n Mod i = 0 Then Judge=true
Next i
Judge= Judge
End Functi...
展开
-
4
Option Explicit
Private Function Judge(n As Integer) As Boolean
Dim i As Integer
For i = 2 To n / 2
If n Mod i = 0 Then Judge = False: Exit Function
Next i
Judge = True
End Function
Private Sub Command1_Click()
Dim x As Integer, i As Integer
x = Val(Text1.Text)
If x = 4 Then
Text2.Text = "2+2"
Else
i = x - 1: Text2.Text = ""
Do While Text2.Text = ""
If Judge(i) Then
Text2 = i & "+" & x - i
Else
i = i - 1
End If
Loop
End If
End Sub