运行下列程序:
Private Sub Form_Click( )
Dim y As Integer, x As Integer
Do Until x > 20
x = x + 10
y = y + x
If x > 20 Then Exit Do
Loop
Print x, y
End Sub
单击窗体后,则在窗体上显示的结果是( )。
A.10 20
B.30 60
C.10 30
D.20 60
第1题:
在窗体上画1个命令按钮,名称为Command1,然后编写如下程序: Dim Flag As Boolean Private Sub Command1_Click() Dim intNum As Integer intNum=InputBox(“请输入:”) If Flag Then Print f(intNum) End If End Sub Function f(X as Integer)As Integer If X<10 Then Y=X Else Y=X+10 End If f=Y End Function Private Sub Form_MouseUp(Button As Integer,Shift As Integer,X as Single,Y As Single) Flag=True End Sub 运行程序,首先单击窗体,然后单击命令按钮,在输入对话框中输入5,则程序的输出结果为______。
A.0
B.5
C.15
D.无任何输出
第2题:
设有如下程序:
Private Sub Form_Click()
Dim i As Integer,x As String,Y As String
x=”ABCDEFG”
For i=4 To 1 Step-1
y=Mid(x,i,i)+y
Next i
Print y
End Sub
程序运行后,单击窗体,输出结果为
A.ABCCDEDEFG
B.AABBCDEFG
C.ABCDEFG
D.AABBCCDDEEFFGG
第3题:
阅读以下应用说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。
【说明8.1】
以下程序的功能是:生成20个200~300之间的随机整数,输出其中能被5整除的数并求出它们的和。
【程序代码8.1】
Private Sub Command1_Click()
For i=1 To 20
x=Int((1)*200+100)
If (2)=0 Then
Print x
S=S+ (3)
End If
Next i
Print"Sum=";S
End Sub
【说明8.2】
程序8.2运行后,单击窗体,则在窗体上显示的内容是:a=(4)和b=(5)。
【程序代码8.2】
Private Sub Form_Click()
Dim a As Integer,b As Integer
a=20:b=50
p1 a,b
p2 a,b
p3 a,b
Print"a=";a,"b=";b
End Sub
Sub p1(x As Integer, ByValy As Integer)
x=x+l0
y=y+20
End Sub
Sub p2(ByVal×As Integer, y As Integer)
x=x+l0
y=y+20
End Sub
Sub p3(ByVal×As Integer, ByVal y As Integer)
x=x+10
y=y+20
End Sub
第4题:
下面程序:
Private Sub Form_Click()
Dim x,y,z As Integer
x=5
y=7
z=0
Call P1(x,y,z)
Print Str(z)
End Sub
Sub P1(ByVal a As Integer, ByVal b As Integer, c As integer)
c=a+b
End Sub
运行后的输出结果为
A.0
B.12
C.Str(z)
D.显示错误信息
第5题:
在窗体上画一个命令按钮,然后编写如下程序 Private Sub Command4 Click() Dim a As Integer,b As Integer a=1 b=2 Print N(a,B)End Sub Function N(x As Integer,y As Integer)As Integer N=IIf(x>y,x,y) End Function 程序运行后,单击命令按钮,输出结果为
A.l
B.2
C.5
D.8
第6题:
有如下事件程序,运行该程序后输出结果是
Private Sub Command33_Click()
Dim X As Integer,y As Integer
x=1:Y=0
Do Until y<=25
y=y+X*X
X=X+1 ‘
Loop ’ 。
MsgBox“x一”&X&,“y=”&y
End Sub
A.x=1,y=0
B.x=4,y=25
C.x=5,y=30
D.输出其他结果
第7题:
单击命令按钮时,下列程序代码的执行结果为( )。 Private Function FirProc(x As Integer,y As Integer,z As Integer) FirProc=2*x+y+3*z End Funcfion Private Function SecProc(x As Integer,y As Integer,z As Integer) SecProc=FirProc(z,x,y)+x End Funcfion Private Sub Command1_Click() Dim a As Integer Dim b As Integer Dim c As Integer a=2 b=3 c=4 Printf SecProc(c,b,a) End Sub
A.21
B.19
C.17
D.34
第8题:
有如下函数过程:
Function HFC(ByVal x As Integer, ByVal y As Integer) As Integer
Do While y <> 0
sic=x / y
x=y
y=sic
Loop
HFC=x
End Function
以下是该函数的调用过程,该程序的运行结果是
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
a=12
b=2
x=HFC(a, B.
Print x
End Sub( )。
A.0
B.6
C.2
D.80
第9题:
单击命令按钮时,下列程序代码的执行结果为______。 Private Sub Proe1 (n As Integer,ByVa1 m As Integer) n=n Mod 10 m=m\ 10 End Sub Private Sub Command1_Click() Dim x As Integer Dim y As Integer x= 12 y = 34 Call Proe1 (x, y) Print x; y End Sub
A. 12 34
B.2 34
C.2 3
D.12 3
第10题:
单击按钮时,以下程序运行后的输出结果是 Private Sub proc1(x As Integer,y As Integer,z As Integer) x=3*z y=2*z z=x+y End Sub Private Sub Command1_Click() Dim x As Integer,y As Integer,Z As Integer x=1:y=2:z=3 Call proc1(x,x,z) Print x;x;z Call proc1(x,y,y) Print x;y;y End Sub
A.6 6 12 `
B.9 5 10 6101051010
C.9 6 12
D.9 10 10 910155410