在窗体上画一个名称为Commandl的命令按钮,然后编写如下程序: Dim SW As Boolean Function func(X AS Integer)As Integer If X<20 Then Y=X Else Y=20+X End If rune=Y End Function Private Sub Form MouseDown(Button As Integer, Shift As Integer,X As Single,Y As Single) SW=False End Sub Private Sub Form MouseUp(Button As Integer, Shift As Integer,X As Single,Y As Single) SW=True End Sub Private Sub Commandl Click() Dim intNum As Integer intNum=InputBox(“”) If SW Then Print func(intNurn) End If End Sub 程序运行后,单击命令按钮,将显示一个输入对话框,如果在对话框中输入25,则程序的执行结果为( )。
【正确答案】 D
【答案解析】解析:调用func(inNum)的返回值为45。当鼠标在单击命令按钮前,SW默认值为False,当单击窗体,也就是按顺序调用Form_MouseDown()和Form_Mouse后SW的值才为True。所以在只是单击按钮,输入25的情况下,SW的值为False,并不打印结果,故程序无任何输出。