工学

单选题假定有如下事件过程: Private Sub Form_MouseDown(Button as Integer,Shift as Integer, X as Single,Y as Single) If Button=2 Then PopupMenu PopForm End Sub 则以下描述中错误的是( )。A 该过程的功能是弹出一个菜单B popForm是在菜单编辑器中定义的弹出式菜单的名称C 参数X、Y指明鼠标的当前位置D Button=2表示按下的是鼠标左键

题目
单选题
假定有如下事件过程: Private Sub Form_MouseDown(Button as Integer,Shift as Integer, X as Single,Y as Single) If Button=2 Then PopupMenu PopForm End Sub 则以下描述中错误的是( )。
A

该过程的功能是弹出一个菜单

B

popForm是在菜单编辑器中定义的弹出式菜单的名称

C

参数X、Y指明鼠标的当前位置

D

Button=2表示按下的是鼠标左键

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

对窗体编写如下事件过程: Private Sub Form_ MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single) If Button =2 Then Print “AAAAA” End If End Sub Private Sub Form_ MouseUp (Button As Integer,Shift As Integer,X As Single,Y As Single) Print “BBBBB” End Sub 程序运行后,如果单击鼠标右键,则输出结果为______ 。

A.AAAAA BBBBB

B.BBBBB

C.AAAAA

D.BBBBB AAAAA


正确答案:A

第2题:

( 25 )要求当鼠标在图片框 P1 中移动时,立即在图片框中显示鼠标的位置坐标。下面能正确实现上述功能的事件过程是

A )

Private Sub P1_MouseMove ( Button AS Integer,Shift As Integer,X As Single,

Y As Single )

Print X,Y

End Sub

B )

Private Sub P1_MouseDown ( Button AS Integer,Shift As Integer,X As Single,

Y As Single )

Picture.Print X,Y

End Sub

C )

Private Sub P1_MouseMove ( Button AS Integer,Shift As Integer,X As Single,

Y As Single )

P1.Print X,Y

E n d S u b

D )

Private Sub Form_MouseMove ( Button AS Integer,Shift As Integer,X As Single,

Y As Single )

P1.Print X,Y

End Sub


正确答案:C

第3题:

执行下列程序后,鼠标单击窗体,输出结果为 。

Private Sub Form_Click()

Print "Click";

End Sub

Private Sub Form_MouseDown(Button As Integer, Shift _

As Integer, X As Single, Y As Single)

Print "Donw"

End Sub

Private Sub Form_MouseUp(Button As Integer, Shift _

As Integer, X As Single, Y As Single)

Print " Up"

End Sub( )。

A.DownUpClick

B.ClickDownUp

C.DownClickUp

D.UpDownClick


正确答案:A

第4题:

假定有如下事件过程: Private Sub Form. MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single) If Button=2 Then PopupMenu popForm End if End Sub 则以下描述中错误的是______。

A.该过程的功能是弹出一个菜单

B.popForm是在菜单编辑器中定义的弹出式菜单的名称

C.参数X、Y指明鼠标的当前位置

D.Button=2表示按下的是鼠标左键


正确答案:D
解析:VisualBasic中没有提供专门的鼠标右击事件,但是在窗体的MouseDown事件里面,通过Button的值可以判断以后单击鼠标的键,当Button=1时,表示用户单击了鼠标左键。当Button=2时,表示用户单击了鼠标右键。因此应该选择D。VisualBasic中常常在MouseDown事件过程中调用PopupMenu方法弹出菜单。

第5题:

设已经在菜单编辑器中设计了窗体的快捷菜单,其顶级菜单为Bt,取消其“可见”属性,运行时,在以下事件过程中,可以使快捷菜单相应鼠标右键菜单的是

A.Private Sub Form_MouseDown(Button As Integer, Shift As Integer,_ X As Single, Y As Single) If Button=2 Then PopupMenu Bt, 2 End Sub

B.Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) PopupMenu Bt End Suh

C.Private Sub Form. MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) PopupMenu Bt,0 End Sub

D.Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If (Button=vbLeftButton) Or ( Button=vbRightButton) Then PopupMenu Bt End Sub


正确答案:A
解析:在VisualBasic中,允许出现快捷菜单,对用户来说,提供了很大的方便,一般来说,菜单都在窗口的顶部,有时,用户需要执行菜单中的某一命令,就得把鼠标移动到窗口顶部,然后打开菜单选择命令,这对用户来说,会觉得麻烦。而快捷菜单并不需要到窗口的顶部来打开,只要单击鼠标右键,就会弹出菜单。设计快捷菜单仍然可以用VisualBasic中提供的菜单编辑器,只要把某个菜单设置成隐藏就可以了,实际上,不管是在窗口顶部菜单条上显示的菜单还是隐藏的菜单,都可以用PopupMenu方法把它们作为快捷菜单在运行时显示出来。PopupMenu方法的使用形式如下:[对象].PopupMenu菜单名,标志,x,y其中,x,y是提供菜单显示的位置;标志:指定快捷菜单的行为。当标志为0时,快捷菜单中的项只能对鼠标左键起反应;当标志为2时,快捷菜单中的项对鼠标右键和左键都反应;标志为2时,PopupMenu方法只能用在MouseDown事件过程中。

第6题:

假定已经在菜单编辑器中建立了窗体的弹出式菜单,其顶级菜单项的名称为a1,其“可见”属性为False。程序运行后,单击鼠标左键或右键都能弹出菜单的事件过程是

A.Private Sub Form_MouseDown(Button As Integer,_ Shift As Integer,X As Single,Y As Single) If Button=1 And Button=2 Then PopupMenu a1 End If End Sub

B.Private Sub Form_MouseDown(Button As Integer,_ Shift As Integer,X As Single,Y As Single) PopupMenu a1 End Sub

C.Private Sub Form_MousoDown(Button As Integer,_ Shift As Integer,X As Single,Y As Single) If Button=1 Then PopupMenu a1 End If End Sub

D.Private Sub Form_MouseDown(Button As Integer,_ Shift As Integer,X As Single,Y As Single) If Buaon=2 Then PopupMenu a1 End If End Sub


正确答案:B
解析:单击左键或者右键均可以弹出菜单,因此不需进行判断单击的哪个键。因此本题答案为B)。

第7题:

下面程序是由鼠标事件在窗体上画图,如果按下鼠标可以画图,双击窗体则可以清除所画图形。补充完整下面的程序。首先在窗体层定义如下变量:

Dim PaintStart As Boolean

编写如下事件过程:

Private Sub Form_Load()

DrawWidth=2

ForeColor=vbGreen

End Sub

Private Sub Form_MouseDown(Button As Integer,Shift As Integer,X AS Single,Y AS Single)

PaintStart=True

End Sub

Private Sub Form_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)

If PaintStart Then

PSet(X,Y)

End If

End Sub

Private Sub Form_MouseUp(Button As Integer,Shift As Integer,X As Single,Y As Single)

End Sub

Private Sub Form_DblClick()

Cls

End Sub


正确答案:PaintStart=False
PaintStart=False 解析:上述过程定义了一个布尔型变量PaintStart,当按下鼠标左键(触发MouseDown事件)时,由题意按下鼠标键表示能画图,所以该变量的值为Tine,而松开鼠标左键(触发MouseUp事件)时,该变量为False;如果变量PaintStart为True,则移动鼠标 (触发MouseMove事件),将在窗体上绘出一个点;除鼠标事件外,上述程序还含有一个Load事件过程和一个DblClick事件过程,其中Load事件过程用来设置画点的大小和颜色,DblClick事件过程用来清除所画的图形,函数Pset是画点语句,用它可以在(x,y) 处画一个点。

第8题:

编写如下事件过程:

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _

X As Single, Y As Single)

If Shift=6 And Button=2 Then

Print "PC"

End If

End Sub

程序运行后,为了在窗体上输出"PC",应执行的操作为( )。

A.同时按下Shift键和鼠标左键

B.同时按下Ctrl,Alt键和鼠标右键

C.同时按下Shift键和鼠标右键

D.同时按下Ctrl,Alt键和鼠标左键


正确答案:B

第9题:

设已经在“菜单编辑器”中设计了窗体的快捷菜单,其顶级菜单为Bs,取消其“可见”属性,运行时,在以下事件过程中,可以使快捷菜单响应鼠标右键菜单的是

A.Private Sub Form_MouseDown(Button As Integer,Shift As Integer,_X As Single,Y As Single) If Button=2 Then PopupMenu Bs,2 End Sub

B.Private Sub Form_MouseDown(Button As Integer,Shift As Integer,_X As Single,Y As Single) PopupMenu Bs End Sub

C.Private Sub Form_MouseDown(Button As Integer,Shift As Integer,_X As Single,Y As Single) PopupMenu Bs,0 End Sub

D.Private Sub Form_MouseDown(Button As Integer,Shift As Integer,_X As Single,Y AS Single) If(Button=vbLeftButton)Or(Button=vbRightButton)Then PopupMenu Bs End Sub


正确答案:A
解析:考查弹出式菜单的使用方法。
  [解题要点] 实际上,不管足在窗口顶部菜单条上显示的菜单,还是隐藏的菜单,都可以用PopupMenu方法把它们作为快捷菜单在运行时显示出来。PopupMenu方法的使用形式如下:
  [对象].PopupMenu菜单名,标志,x,y。
  其中,x,y是提供菜单显示的位置;标志指定快捷菜单的行为。
  [考点链接] 使用菜单编辑器制作菜单。

第10题:

编写了如下事件过程: Private Sub Form_MouseDown(KeyCode As Integer,Shift As Integer) If (Button And 3)=3 Then Print"AAAA" End If End Sub 程序运行后,为了在窗体上输出“AAAA”,应按下的鼠标键是

A.左

B.右

C.同时按下左和右

D.按什么键都不显示


正确答案:D
解析:本题主要是对if语句的考查。如果if语句后的条件为真,则执行Then后边的语句,否则不执行。Button And 3是一个逻辑表达式,其结果只可能为。或1,故条件 (ButtonAnd 3)=3永远不成立,即语句print“AAAA”永远都不被执行。根据上面的分析可知选项D正确。

更多相关问题