一、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