(29)有如下函数:
Function fun(a As Integer,n As Integer) As Integer
Dim m As Integer
While a >=n
a=a-n
m= m+1
Wend
fun=m
End Function
该函数的返回值是 。
A)a乘以n的乘积 B)a加n的和
C)a减n的差 D)a除以n的商(不含小数部分)
(30)下面程序的输出结果是 。
Private Sub Command1_Click()
ch$=”ABCDEF”
proc ch
Print ch
End Sub
Private Sub proc(ch As String)
S=””
For k=Len(ch) To 1 Step-1
s=s&Mid(ch,k,1)
Next k
ch=s
End Sub
A)ABCDEF B)FEDCBA C)A D)F
(31)某人编写了一个能够返回数组a中10个数中最大数的函数过程,代码如下:
Function MaxValue(a() As Integer) As Integer
Dim max%
max=1
For k = 2 To 10
If a(k)>a(max) Then
max = k
End If
Next k
MaxValue = max
End Function
程序运行时,发现函数过程的返回值是错的,需要修改,下面的修改方案中正确的是 。
A)语句max = 1应改为max = a(1)
B)语句For k = 2 To 10应改为For k = 1 To 10
C)If语句中的条件a(k)>a(max)应改为a(k)>max
D)语句MaxValue = max 应改为MaxValue = a(max)
(32)在窗体上画一个名称为Command1的命令按钮,并编写以下程序:
Private Sub Command1_Click()
Dim n%,b,t
t = 1:b = 1:n = 2
Do
b = b*n
t = t + b
n = n +1
Loop Until n>9
Print t
End Sub
此程序计算并输出一个表达式的值,该表达式是 。
A)9! B)10! C)1!+2!+…+9! D)1!+2!+…+10!
(33)有一个名称为Form1的窗体,上面没有控件,设有以下程序(其中方法Pset(X,Y)的功能是在坐标X,Y处画一个点):
Dim cmdmave As Boolean
Private Sub Form_MouseDown(Button As Integer,Shift As Integer, X As Single,Y As Single)
cmdmave = True
End Sub
Private Sub Form_MouseMove(Button As Integer,Shift As Integer, X As Single, Y As Single)
If cmdmave Then
Form1.Pset(X,Y)
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single,Y As Single)
cmdmave = False
End Sub
此程序的功能是 。
A)每按下鼠标键一次,在鼠标所指位置画一个点
B)按下鼠标键,则在鼠标所指位置画一个点;放开鼠标键,则此点消失
C)不按鼠标键而拖动鼠标,则沿鼠标拖动的轨迹画一条线
D)按下鼠标键并拖动鼠标,则沿鼠标拖动的轨迹画一条线,放开鼠标键则结束画线
考试信息
热点
课程
更新