Private Sub Form_Click() A$ = \ C = Val(A$) + Val(B$) Print C \\ 100 End Sub
3. 下面程序运行后输出结果是_______。
Private Sub Form_Click()
X$ = \
X$ = Y$ & X$ : Y$ = Y$ & Z$: Z$ = X$ & Z$ & Y$ Print X$ + Y$ + Z$ End Sub
4. 下列程序段的执行结果为 ()。
Private Sub Form_Click() X=1:Y=2
Z=X=Y Print X;Y;Z End Sub
三、选择题
1. Inputbox函数的参数中,必选参数的作用是( )。 A.输出信息 B.定义提示信息 C.定义隐含信息 D.定义输入的位置
2. 假设变量B是一个布尔型变量,则下面正确的赋值语句是( )。 A.B=T B.B=”True” C.B=#True# D.B=3<4 3.下列程序执行的结果为( )。
x=5:y=6:z=7 Print “a(“;x+z*y;”)”
A.a( 47 ) B.a(72) C.a(5+6*7) D.a(47)
4. 以下程序段可以实现X、Y变量值交换的是( )。 A.Y=X:X=Y B.Z=X:Y=Z:X=Y
C.Z=X:X=Y:Y=Z D.Z=X:W=Y:Y=Z:X=Y 5.下述程序的运行结果是( )。
A=5 B=-5 C=NOT A=B Print C
A.True B.5 C.0 D.无法输出
6.如果将布尔常量False赋值给一个整型变量,则整型变量的值为( )。 A.0 B.-1 C.True D.False
7.用X、Y、Z表示三角形的三条边,条件“三角形任意两边之和大于第三边”的布尔表达式可以用( )表示。
A. X+Y>Z And X+Z>Y And Y+Z>X B. X+Y
第三章
一、思考题 略
二、程序阅读题
1. A=2 B=1 C=2
2. 12
3. BABCBACBC 4. 1 2 False
三、选择题
1.B 2.D 3.A 4.C 5.A
第四章 一、判断题
1.错 2.错 3.错 4.错 5.对
二、选择题
1.A 2. D 3.A 4.B 5.A
三、程序阅读题 1.
x=0 y=7 2. w=4 w=13 w=135 w=31
3. s=1 s=2 s=5 s=20
四、程序填空题
6.A 7.A 6.A 1.
(1) max (2)min (3)c>max (4)c (1) x mod 3=2 and x mod 5=3 and x mod 7=4 then (2) text1.setfocus 五、 1. Private Sub Command1_Click() Dim y As Integer y = Val(InputBox(\ If (y Mod 4 = 0 And y Mod 100 <> 0) Or (y Mod 400 = 0) Then Print \是闰年\ Else Print \不是闰年\ End If End Sub 2. Private Sub Command1_Click() Dim a%, b%, c%, x!,s! a = Val(InputBox(\ b = Val(InputBox(\ c = Val(InputBox(\ If a + b > c And a + c > b And b + c > a Then x = (a + b + c) / 2 s = Sqr(x * (x - a) * (x - b) * (x - c)) Print \ Else Print \不是三角形,重输a,b,c\ End If End Sub 3. Private Sub Command1_Click() Dim x!, y! x = Val(InputBox(\ If x < 0 And x <> -3 Then y = x * x + x – 6 elseIf 0 <= x And x < 10 And x <> 2 And x <> 3 Then y = x *sin(x) +2^ x else y=sqr(x+5)+log(x+4)/log(10) End If Print \ End Sub 4. Private sub form_click() Dim y%,z%,dj%,p!,t! ‘y:月 Z: 订票数 dj: 票价 t:总票价 Y=val(inputbox(“月”)) Z= val(inputbox(“订票数”)) Dj= val(inputbox(“票价”)) Select case y case 7,8,9 If z>=20 then p=0.15 else p=0.05 case 1 to 5,10,11 If z>20 then p=0.3 else p=0.2 Case else P=0.2 End select T=z*dj*p ? t end sub 5. private sub form_click() dim m1%,m2%,m3%,dj$ m1=val(inputbox(“m1=”)): m2=val(inputbox(“m2=”)): m3=val(inputbox(“m3=”)) if (m1+m2+m3)/3>=95 or ( a=100 and b=100 and c>=80) or ( a=100 and c=100 and b>=80) or ( c=100 and b=100 and a>=80) then dj=”一等” elseif (m1+m2+m3)/3>=90 or ( a=100 and b>=75 and c>=75) or ( b=100 and a>=75 and c>=75) or ( c=100 and b>=75 and a>=75) then dj=”二等” elseif a>=75 and b>=75 and c>=75 then dj=”三等” else dj=”没有” endif ? “dj=”;dj end sub 第五章 习题与思考题和答案 一、判断题 1.要实现同样的循环控制,在Do While-Loop和Do-Loop While循环结构中给定的循环条件是一样的。 2.Do-Loop While语句实现循环时,不管条件真假,首先无条件地执行一次循环。 3.Do-Loop Until语句实现循环时,只要条件是假,循环将一直进行下去。 4.一个Do循环只能使用一个Loop关键字,但是可以使用多个Exit语句。 5.For循环语句正常结束(即不是通过Exit For语句或强制中断)其循环控制变量的值一定大于“终值”,并等于“终值”+“步长”。 6.如果有多重Do循环嵌套,位于最里层循环体语句中的Exit Do语句可以退出所有的循环。 7.For-Next循环结构的默认步长为1。 8.Do-Loop语句是循环结构的一种特殊形式,如果循环体中没有Exit Do语句,程序运行就一定会进入死循环。 二、选择题 1.循环结构 For i!=1 to 10 step 1.5 共执行几次 。 A.6 B.7 C.9 D.10 2.下列循环正常结束的是 。 A.i=0 B.i=0 Do Do While i<0 i=i-1 i=i-1 Loop While i<0 Loop C.i=10 D.i=6 Do Do i=i+1 i=i-2 Loop Until i<0 Loop Until i=1 3.下列哪组语句可以将变量A、B值互换 。 A.A=B : B=A B.A=A+B : B=A – B: A=A – B C.A=C : C=B : B=A D.A=(A+B)/2 : B=(A – B)/2