35. 运行下列程序,输入数据8、9、3、0后,窗体中的显示结果是______。 Private Sub Form_click() Dim sum As Integer, m As Integer sum=0 Do m=InputBox("输入m") sum=sum+m Loop Until m=0 MsgBox sum End Sub
36. 窗体中有命令按钮Command1和文本框Text1,事件过程如下: Function result(ByVal x As Integer) As Boolean If x Mod 2=0 Then result=True Else result=False End If End Function Private Sub Command1_Click() x=Val(InputBox("请输入一个整数")) If[ ]Then Text1=Str(x) & "是偶数." Else Text1=Str(x) & "是奇数." End If End Sub 运行程序,单击命令按钮,输入19,在Text1中会显示“19是奇数”。那么在程序的括号内应填写______。
37. 若有如下Sub过程: Sub sfun(x As Single, y As Single) t=x x=t/y y=t Mod y End Sub 在窗体中添加一个命令按钮Command33,对应的事件过程如下: Private Sub Command33_Click() Dim a As Single Dim b As Single a=5:b=4 sfun(a, b) MsgBox a & chr(10)+chr(13) & b End Sub 打开窗体运行后,单击命令按钮,消息框中有两行输出,内容分别为______。
A.1和1
B.1.25和1
C.1.25和4
D.5和4
A B C D
B
[解析] 此题中设定了一个sfun()函数,进行除法运算和求模运算。命令按钮的单击事件中,定义两个变量a=5,b=4,调用sfun函数传递a,b的值给x,y进行运算,t=x=5,y=4;x=t/y=5/4=1.25(除法运算);y=t Mod y=5 mod 4=1(求模运算)。sfun函数参数没有指明参数传递方式,则默认以传址方式传递,因此a的值为1.25,b的值为1。故本题答案为B。
38. 窗体有命令按钮Command1和文本框Text1,对应的事件代码如下: Private Sub Command1_Click() For i=1 To 4 x=3 For j=1 To 3 For k=1 To 2 x=x+3 Next k Next j Next i Text1.Value=Str(x) End Sub 运行以上事件过程,文本框中输出的是______。
39. 在窗体中有一个命令按钮Command1,编写事件代码如下: Private Sub Command1_Click() Dim s As Integer s=P(1)+P(2)+P(3)+P(4) debug.Print s End Sub Public Function P(N As Integer) Dim Sum As Integer Sum=0 For i=1 To N Sum=Sum+i Next i P=Sum End Function 打开窗体运行后,单击命令按钮,输出结果是______。
40. 下列过程的功能是:通过对象变量返回当前窗体的Recordset属性记录集引用,消息框中输出记录集的记录(即窗体记录源)个数。 Sub GetRecNum() Dim rs As Object Set rs=Me.Recordset MsgBox[ ] End Sub 程序括号内应填写的是______。