Next j Print Next i
End Sub
5. 执行下面的程序,在窗体上显示的第一行输出结果是___1 3 5 7 9__,第三行输出结果是___4___, FOrm_Click()事件过程中的第二个For--Next循环共执行了___2___次。 Option Explicit Option Base 1
Private Sub Form_Click()
Dim a(5) As Integer,i As Integer,j As Integer For i=1 To 5
a(i)=2*i-1 Print a(i)
Next i Print
For j=1 To I-2
Call sub1(a(j),j) Print j
Next j
End Sub
Public Sub Sub1(x As Integer,p As Integer)
If x-p<=2 Then
p=p+1
Else
p=p+2
End If
End Sub
6.下面程序的功能是统计随机产生的十个两位正整数中偶数于奇数的个数,并求出偶数与奇数各自的总和。 Option Explicit
Private Sub Form_Click()
Dim x As Integer, s1 As Integer,s2 As Integer Dim n1 As Integer, n2 As Integer,i As Integer Randomize For i=1 To 10
x=Int(Rnd*90)+10 Print x
If __x mod 2=0___Then
n2=n2+1 s2=s2+x Else
___n1=n1+1___ s1=s1+x End If
Next i
Print \奇数个数=\偶数个数=\
7. 下面程序功能为:单击命令按纽Command1,找出100以内的所有约数之和为一个完全平方数的正整数,并按图中所示的格式将结果显示在图形框Picture1中。
Option Explicit
Private Sub Command1_Click()
Dim i As Integer,j As Integer Dim F() As Integer,sum As Integer
For i=3 To 100
___sum=0___ If Fac(i,F,sum) Then
Picture1.Print i; \ FOr j=1 To UBound(F)-1
Picture1.Print F(J); \ Next J
Picture1.Print F(J); \ End If Next i End Sub
Private Function Fac(ByVal K As Integer,A() As Integer,sum As Integer) As Boolean
Dim N As Integer,J As Integer For N=1 To K