vb 求助下各位

来源:百度知道 编辑:UC知道 时间:2024/05/16 01:47:40
a*b=c

只给出c的值 怎样才会返回a,b的值。

也就是说我给出一个数字例如 21

则 txt1和txt2会返回 3 和 7 或 7和3

谢谢

Public Function GetFactorArray(ByVal n As Long)
'返回质因子的乘积
Dim arr()
Dim m As Long
For i = 2 To n / 2
Do While n <> 1
If n Mod i = 0 Then
ReDim Preserve arr(m)
arr(m) = i
m = m + 1
n = n / i
Else
Exit Do
End If
Loop
Next i
GetFactorArray = arr
End Function

private sub Command1_Click()
print join(GetFactorArray(21),"*")
end sub

可能不只一种情况,比如2*10=20
4*5=20

不错呀,上面回答