大学vb复习资料2
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
四、阅读程序写结果
1、下列程序的输入值为15时,其运行结果为( )。
Dim a as integer
A = InputBox("请输入a的值")
Select case A
Case 1 to 4
Print "D"
Case 5 to 10
Print "C"
Case IS=15
Print "B"
Case else
Print "A"
End select
2、下列程序段的执行结果是()。
A = 0 : b = 0
For I = -1 To -2 Step -1
For j = 1 To 2
b = b + 1
Next j
a = a + 1
Next I
Print a; b
3、有如下一个函数过程:
Function f(a As Integer)
b = 0
Static c
b = b + 1
c = c + 1
f = a + b + c
End Function
在窗体上添加一个命令按纽,事件过程如下:
Private Sub Command1_Click()
Dim a As Integer
a = 2
For I = 1 To 3
Print f(a);
Next I
End Sub
运行该程序,单击命令按纽,输出结果是()。
4、在窗体上添加一命令按纽,名为Command1,然后为该命令按纽编写如下事件过程,该过程执行结果为()。
Option base 1
Private Sub Command2_Click()
Dim a As Variant
Dim s As integer
a = Array(1, 2, 3, 4)
j = 1
For I = 1 To 4 Step 1
s = s + a(I) * j
j = j * 10
Next I
Print s
End Sub
5、下列程序的执行结果是( )。
Private Function P(N As Integer)
For I = 1 To N
SUM = SUM + 1
Next I
P = SUM
End Function
Private Sub Command1_Click()
S = P(1) + P(2) + P(3) + P(4)
Print S;
End Sub
6、下列程序段的执行结果为( )。
有如下SUB过程:
Sub s(x As Single, y As Single)
t = x
x = t / y
y = t Mod y
End Sub
在窗体上添加一个命令按纽,然后编写如下事件过程:
Private Sub Form_Click()
Dim a As Single
Dim b As Single
a = 5
b = 4
s a, b
Print a, b
End Sub
则程序运行后,单击命令按纽,输出的结果为 ( )
7、在窗体上添加一命令按纽,名为Command1,然后为该命令按纽编写如下事件过程,该过程执行结果为()。
Option base 1
Private Sub Command2_Click()
Dim a As Variant
a = Array(1, 2, 3, 4)
j = 1
For I = 4 To 1 Step -1
s = s + a(I) * j
j = j * 10
Next I
Print s
End Sub
8、下列命令按纽事件过程执行后,输出结果是:
For m = 1 To 1000 Step 2
a = 10
For n = 1 To 20 Step 2
a = a + 2
Next n
Next m
Print a
9、在窗体上添加一个命令按钮,名为command1,一文本框,名为text1,则执行如下事件过程后,文本框中的输出为()。
For I = 1 To 4
For j = 1 To 3
x = 3
For k = 1 To 2
x = x + 3
Next k
Next j
Next I
Text1.Text =str( x)
10、在窗体上建立三个文本框,名称分别为Text1、Text2和Text3,一个命令按纽,名称为command1,如果在TEXT1中输入数200,在TEXT2中输入数150,则执行下列程序后,TEXT3的值为()。
Private Sub Command1_Click()
Dim m, n As Integer
m = Val(Text1.Text) : n = Val(Text2.Text)
If n * m = 0 Then
Exit Sub
End If
If m < n Then
t = m: m = n: n = t
End If
Do
r = m Mod n
m = n
n = r
Loop While r <> 0