单选题
VB
题号 #2537599
在窗体上画一个名称为Co mmand1的命令按钮,然后编写如下程序:
Di mSW As Boolean
Function func(X As Integer)As Integer
If X<20Then
Y =X
Else
Y =20+X
End If
func =Y
End Function
Private Sub Form_MouseDown(Button As Integer ,_
Shift As Integer ,X As Si ngle ,Y As Si ngle)
SW=False
End Sub
Private Sub Form_Mouse Up(Button As Integer ,_
Shift As Integer ,X As Si ngle ,Y As Si ngle)
SW=True
End Sub
Private Sub Co mmand1_Click()
Di mi nt Num As Integer
i nt Num=InputBox("")
If SW Then
Print func(i nt Num)
End If
End Sub
程序运行后,单击命令按钮,将显示一个输入对话框,如果在对话框中输入25,则程序的执行结果为( )。
参考答案
D
答案解析
调用func(i nNum)的返回值为45。当鼠标在单击命令按钮前,SW 默认值为False ,当单击窗体,也就是按顺序调用Form_MouseDown()和Form_Mouse Up 后SW 的值才为True。所以在只是单击按钮,输入25的情况下,SW 的值为False ,并不打印结果,故程序无任何输出。
你可能感兴趣的试题
A.使用Append 方式打开文件时,文件指针被定位于文件尾
B.当以输入方式(Input)打开文件时,如果文件不存在,则建立一个新文件
C.顺序文件各记录的长度可以不同
D.随机文件打开后,既可以进行读操作,也可以进行写操作
A.在工程属性对话框中把"启动对象"设置为Form2
B.在Forml 的Load 事件过程中加入语句Load Form2
C.在Form2的Load 事件过程中加入语句Form2.Show
D.把Form2的TabIndex 属性设置为l ,把Form1的TabIndex 属性设置为2
A.Private Sub Co mmand1_Click()
Open "out .txt"For Input As #1
Print #1,Text1.Text
Close #1
End Sub
Open "out .txt"For Input As #1
Print #1,Text1.Text
Close #1
End Sub
B.Private Sub Co mmand1_Click()
Open "out .txt"For Output As #1
Print #1,Text1.Text
Close #1
End Sub
Open "out .txt"For Output As #1
Print #1,Text1.Text
Close #1
End Sub
C.Private Sub Co mmand1_Click()
Open "out .txt"For Append As #1
Print #1,Text1.Text
Close #1
End Sub
Open "out .txt"For Append As #1
Print #1,Text1.Text
Close #1
End Sub
D.Private Sub Co mmand1_Click()
Open "out .txt"For Rando m As #1
Print #1,Text1.Text
Close #1
End Sub
Open "out .txt"For Rando m As #1
Print #1,Text1.Text
Close #1
End Sub