0

Currently I've attached a function to a command button on my form which retrieves what the user inputs into the textbox on the form; this works fine but I want to emulate this behaviour with the ENTER key. How can I go about doing this?

I tried the Enter Property on the textbox but that only occurs when focus has been transfered to the textbox, not when i press enter after input.

I've read about the KeyUp event for VB but there's got to be an easier way - I've googled this but can't find what Im looking for. Any suggestions?

Thanks

4

1 に答える 1

1

多くの場合、After Update イベントは、テキスト ボックスに入力されたデータの操作に適しています。次に例を示します。

Private Sub txtFilter_AfterUpdate()
    Me.Filter = "Content " & Me.txtFilter.Text
    Me.FilterOn = True
End Sub

ただし、データを編集または検証する必要がある場合は、更新前の方が適しています。

Private Sub txtText_BeforeUpdate(Cancel As Integer)
    If Me.txtText = "Invalid" Then
        Me.Undo
        Cancel = True
    End If
End Sub
于 2013-01-17T17:01:06.163 に答える