Hello everybody,

I have a question about vb.Net.
I really hope that you can help me with it.

I've got a form with several textboxes.
When the user gives input in an textbox and presses the tabkey,
then the input in the textbox must be checked and complement with data.
Seems to me that this must be a simple thing, but it will not work and i can't find anathing about it.

The code must be something like this:
If (code for user presses the tabkey) and ChkStart1.IsMatch(txtStart.Text) Then
Start = Me.txtStart.Text & ".000"
End If

Can anabody help me with this.

Thanks in advance,

Sneaky Pete

  1. Goto your form's property window and make sure 'KeyPreview' is true.
  2. Goto your form's events windows and make an event for 'KeyUp'.
  3. Insert the following code into the event subroutine you made in step 2.

    If e.KeyCode = Keys.Tab And ChkStart1.IsMatch(txtStart.Text) Then
        Start = Me.txtStart.Text & ".000"
    End If
    
  4. In the end it should look something like this:

    Public Class MyForm
        Public Start As String
    
        Private Sub MyForm_KeyUp(sender As Object, e As KeyEventArgs) Handles MyBase.KeyUp
            If e.KeyCode = Keys.Tab And ChkStart1.IsMatch(txtStart.Text) Then
                Start = Me.txtStart.Text & ".000"
            End If
        End Sub
    End Class
    

Thanx Pride!

The tab function is working!

No problem :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.