.
4、option base、ubound、lbound 5、强制变量声明
6、表示a2是一个可选参数 7、End
8、Msgbox、Inputbox 9、*.*、showprint 10、Mid() 11、6
12、redim preserve arraya(ubound(arraya())+1) 13、static 14、0 15、f 16、rem、’ 17、变量、数组 18、1 to 4,1 to 5 19、Index 20、按地址 21、Option Explicit 22、13 23、ityo 24、符号 25、LCase 26、ESC 27、部件 28、断点 29、False
30、Option Explicit 31、UCase 32、Mid 33、#
31 / 52
.
34、过程 35、private 36、求x的绝对值 37、2.5
二、选择题
1、D 2、B 3、D 4、C 5、B 6、C 7、D 8、C 9、D 10、A 11、A 12、D 13、B 14、B 15、D 16、B 17、A 18、D 19、D 20、C 21、D 22、B 23、B 24、B 25、B
32 / 52
.
26、A 27、B 28、C 28、B 30、C
四、读程序题
1、结果如下:
B
2、结果如下:
BB CCC DDDD EEEEE
3、功能如下:
在20个由小到大排列的数据中插入一个数,插入数据后的数据仍按由小到大的顺序排列。
4、输出结果为:
2 4 6 8 5、输出结果为:
3
6、输出结果为:
2 452
7、输出结果为:
120 0 2 0
8、输出结果为:
33 / 52
.
3 3 3 2
五、编程题
1、参考代码如下:
Private Sub Command1_Click() Dim year, x As Integer year = Val(Text1.Text) If year Mod 400 = 0 Then Label2.Caption = \是闰年\ Else
' 下面是嵌套块If语句
If year Mod 4 = 0 And year Mod 100 <> 0 Then Label2.Caption = \是闰年\ Else
Label2.Caption = \不是闰年\ End If End If End Sub
2、程序参考代码如下:
Private Sub Command1_Click() Dim m, n, r As Integer m = Val ( Text1.Text ) n = Val ( Text2.Text )
If m < 0 Or n < 0 Then ‘ 若判断为非法数据,Then子句输出相应信息 Label2.Caption = \输入数据有错!\
Else ‘ 若判断为合法数据,Else子句用辗转相除法求余数
r = m Mod n Do While r <> 0 m = n
34 / 52
.
n = r r = m Mod n Loop
‘ 循环结束后n中存放的就是最大公约数,输出n值 Label2.Caption = \最大公约数为:\ End If End Sub
3、参考代码如下:
Private Sub Command1_Click() Dim x As Single x = Val(Text1.Text) If x > 100 Or x < 0 Then Text2.Text = \ ElseIf x < 60 Then
Text2.Text = \不及格\ ElseIf x < 70 Then Text2.Text = \及格\ ElseIf x < 80 Then Text2.Text = \中等\ ElseIf x < 90 Then Text2.Text = \良好\ Else
Text2.Text = \优秀\End If End Sub
4、参考代码如下:
Private Sub Form_Load() Dim i As Integer Show '使输出可见 Form1.Font = \新宋体\
35 / 52
VisualBasic程序设计教程第三版课后习题答案 - 图文



