用VB编写输入一个正整数N,把它分解成质因子相乘的形式.如输入36,输出36=1×2×2×3×3

问题描述:

用VB编写输入一个正整数N,把它分解成质因子相乘的形式.如输入36,输出36=1×2×2×3×3
不用text的形式,应如何去做

Dim n%,cs,i%
n = Text1
cs = "1":i = 2
Do
If n Mod i = 0 Then
n = n / i:cs = cs & "×" & i
Else
i = i + 1
End If
Loop While i Option Explicit
Private Sub Command1_Click()
Dim n%,cs,i%
n = InputBox("","",36)
cs = n & "=1":i = 2
Do
If n Mod i = 0 Then
n = n / i:cs = cs & "×" & i
Else
i = i + 1
End If
Loop While i MsgBox cs
End Sub