Private Sub Command1_Click()
Dim m As Long
m = InputBox("请输入一个正整数:", "求一个正整数的所有因子", Int(Rnd * 1000000 + 1))
Print m & "的因子有:1 ";
If m > 1 Then
For i = 2 To m
If m Mod i = 0 Then Print i;
Next i
End If
End Sub
Private Sub Form_Click()
Dim m As Integer
Dim strA As String
strA = 1
m = InputBox("输入一个整数")
If m = 1 Then
MsgBox m & "的所有因子:1," & m
Exit Sub
End If
For i = 2 To m
If m Mod i = 0 Then
strA = strA & "," & i
m = m / i
End If
Next i
MsgBox m & "的所有因子:" & strA & ","
End Sub