谁能用VB 帮我写个分解质因数的小程序? 假设在文本框text1中输入12, 然后点击命令按钮

2024-11-21 09:34:06
推荐回答(1个)
回答1:

Private Sub Command1_Click()
n = Val(Text1.Text)
Do While i < n
For i = 2 To n - 1
If n Mod i = 0 Then
n = n \ i
s = s & i & "*"
Exit For
End If
Next i
Loop
Text2.Text = s & n
End Sub