我的世界经验指令大全:VB中这两个sub怎么用(视回答加分10-50)新新新

来源:百度文库 编辑:神马品牌网 时间:2024/04/30 04:01:02
请举例说明
Private Sub tx_input_GotFocus(Index As Integer)

End Sub

Private Sub tx_input_KeyPress(Index As Integer, KeyAscii As Integer)

End Sub

首先说明你的Tx_input是文本框控件数组,下面给出代码,GotFocus事件是获得焦点时发生的事件,KeyPress是按键盘键时发生的事件.
Private Sub Tx_input_GotFocus(Index As Integer)
'可写其它需执行的代码
Tx_input(0) = "123"
Tx_input(1) = ""
End Sub

Private Sub Tx_input_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then '按下ENTER键
'可写其它需执行的代码
Tx_input(0) = "ABC"
Tx_input(1) = "AAA"
End If
End Sub