编写如下事件过程: Private Sub Form_MouseDown(Button AS Integer,Shift AS Integer,_

题目

编写如下事件过程: 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键和鼠标左键

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

第1题:

编写如下事件过程:

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

第2题:

对窗体编写如下事件过程: 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

第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_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If (Button And 3) = 3 ThenPrint "AAAA"End IfEnd Sub程序运行后,为了在窗体输出“AAAA”,应按下的鼠标键为()

A、左

B、右

C、同时按下左、右

D、按什么键都不显示


参考答案D

第5题:

( 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

第6题:

编写如下事件过程,当程序运行后,为了在窗体上输出BBBB,应执行的操作为 ______ 。 Private Sub Form_MouseDown(Button As Integer,_ Shift As Integer,X As Single,Y As Single) If Shift = 6 And Button = 2 Then Print "BBBB" EndIf End Sub

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

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

C.同时按下Ctrl、Alt键和鼠标左键

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


正确答案:D
解析:分析程序可以发现:要在窗体上输出BBBB,必须满足两个条件,即参数Shift=6同时参数Button= 2,关于这两个参数,Shift表示Shift、Ctrl和Alt的状态,Button指示被按下的鼠标键。Shift的值6表示成二进制数得到低三位数110,其中最低位对应Shift键,因为最低位为。所以不需要按下Shift键,而倒数第2位(值为1)对应Ctrl键(该键应该呈按下状态),接下来从最低位开始的倒数第3位(值为1)对应Alt键(该键应该呈按下状态),因此可以排除答案A和B,接下来Button的值2表示成二进制数得到最低三位为010,该三位分别对应鼠标的中间键、右键及左键的状态,因此此时应该是按下鼠标右键,所以可以得到正确答案是选项D。

第7题:

假定已经在菜单编辑器中建立了窗体的弹出式菜单,其顶级菜单项的名称为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)。

第8题:

在以下事件过程中,可以在用户按下鼠标右键时,显示一个上边框,以鼠标当前位置为中心的弹出式菜单,而且这个弹出式菜单还可以识别右键对菜单命令的选择,相应的选项是( )。

A.Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _

X As Single, Y As Single)

If Button=2 Then

PopupMenu mnuEdit, vbPopupMenuCenterAlign Or _

vbPopupMenuRightButton, X, Y, mnuEditOpen

End If

End Sub

B.Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _

X As Single, Y As Single)

If Button=2 Then

PopupMenu mnuEdit,

End If

End Sub

C.Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _

X As Single, Y As Single)

PopupMenu mnuEdit, vbPopupMenuCenterAlign Or _

vbPopupMenuRightButton

End Sub

D.Private Sub Form_MouseUp(Button As Integer , _

Shift As Integer, X As Single, Y As Single)

If Button=2 Then

PopupMenu mnuEdit, 2

End If

End Sub


正确答案:A

第9题:

要求当鼠标在图片框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_M0useDown(Button As Integer,Shift As Integer,X As Single,Y As Single) Picture.Print X,Y End Sub

C.Private Sub P1_MouscMove(Button As integer,Shift As Integer,X As Single,Y As Single) P1.Print X.Y End Sub

D.Private Sub Form_MouseMove(Button As Integer,Shift As Integer,x As Single,Y As Single) P1.Print X.Y End Sub


正确答案:C
解析:鼠标在图片框中移动,对象应为图片框控件,而不是窗体,选项D)是错误的;鼠标移动触发的是MouseMove事件,选项B)是错误的;在图片框内显示坐标,Print的对象名为图片框,如果没有对象名,则默认输出到窗体上,所以正确的答案为C)。

第10题:

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

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) 处画一个点。

更多相关问题