请问以下两道VB题目怎么做1.单击分解按钮,程序提示输入一个大于2的整数,并将该数分解为因数的乘积,代码如下Private Sub Command1_Click() Dim n As Integer, Factor As Integer Dim First As Boolean Do n

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 05:14:07
请问以下两道VB题目怎么做1.单击分解按钮,程序提示输入一个大于2的整数,并将该数分解为因数的乘积,代码如下PrivateSubCommand1_Click()DimnAsInteger,Factor

请问以下两道VB题目怎么做1.单击分解按钮,程序提示输入一个大于2的整数,并将该数分解为因数的乘积,代码如下Private Sub Command1_Click() Dim n As Integer, Factor As Integer Dim First As Boolean Do n
请问以下两道VB题目怎么做
1.单击分解按钮,程序提示输入一个大于2的整数,并将该数分解为因数的乘积,代码如下
Private Sub Command1_Click()
Dim n As Integer, Factor As Integer
Dim First As Boolean

Do
n = InputBox("请输入一个大于2的整数")
If n

请问以下两道VB题目怎么做1.单击分解按钮,程序提示输入一个大于2的整数,并将该数分解为因数的乘积,代码如下Private Sub Command1_Click() Dim n As Integer, Factor As Integer Dim First As Boolean Do n
Option Explicit
Private Sub Command1_Click()
Dim n As Integer, Factor As Integer
Dim First As Boolean

Do
n = InputBox("请输入一个大于2的整数")
If n 2

Factor = 2
First = True

Do
Do While (n Mod Factor = 0)
If First Then
Text1.Text = Str(n) + Space(1) + "=" + Str(Factor)
First = False
Else
Text1.Text = Text1.Text + Space(1) + "*" + Str(Factor)
End If
n = n / Factor
Loop
Factor = Factor + 1
Loop Until Factor > n
End Sub
Private Sub Cmd1_Click()
Dim a(), n%, i%, j%, k%
n = InputBox("请输入控制正方形图案层数的可变数")
ReDim a(n, n)
For k = 1 To (n + 1) \ 2
For i = k To n - k + 1
For j = k To n - k + 1
a(i, j) = k
Next j
Next i
Next k

For i = 1 To n
For j = 1 To n
Print Tab(j * 3); a(i, j);
Next j
Print
Next
End Sub