网站首页 语言 会计 互联网计算机 医学 学历 职场 文艺体育 范文
当前位置:学识谷 > 计算机 > 计算机二级

2015二级计算机考试《VB》复习重点:KeyPress和鼠标事件

栏目: 计算机二级 / 发布于: / 人气:2.1W

 一、KeyPress事件

2015二级计算机考试《VB》复习重点:KeyPress和鼠标事件

在窗体上画一个控件(指前面所讲的可以发生KeyPress事件的控件),并双击该控件,进入程序代码窗口后,从“过程”框中选取KeyPress,即可定义KeyPress事件过程。一般格式为:

Private Sub Text1 _ KeyPress(KeyAscii As Integer)

End Sub

 二、KeyDown和KeyUp事件

KeyDown和KeyUp事件的参数也有两种形式,其中

Index As Integer

只用于控件数组,而

KeyCode As Integer,Shift As Integer

用于单个控件。

 三、鼠标事件

为了实现鼠标操作,Visual Basic提供了3个过程模板:

(一)压下鼠标键事件过程

Sub Form_MouseDown(Button As Integer,Shift As Integer,x As Single,y As Single)End Sub

(二)松开鼠标键事件过程

Sub Form_MouseUp(Button As Integer,Shift As Integer,x As Single,y As Single)End Sub

(三)移动鼠标光标事件过程

Sub Form_MouseMove(Button As Integer,Shift As Integer,x As Single,y As Single)End Sub