Results 1 to 7 of 7

Thread: Validation assistance [Resolved]

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    127

    Validation assistance [Resolved]

    It may not be tidy but I am trying to fine tune the code below to handle validation.

    Code:
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    
            If e.KeyChar.IsNumber(e.KeyChar) = False Then
                e.Handled = True
            End If
    
        End Sub
    
        Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
    
            If e.KeyChar.IsNumber(e.KeyChar) = False Then
                e.Handled = True
            End If
    It works great at keeping anything but numbers from being entered in either TextBox. I need some suggestions / examples if possible on how to force input in both boxes.

    Example: When my form loads it places focus on TextBox1 and the user must enter a number in TextBox1 and then tab over to TextBox2 and place another number in it before they will be allowed to click a button that runs another function in the form. If they don't put input in both TextBoxes I need a MessageBox to show that reminds them to enter numbers in both TextBoxes before they can click any other buttons on the form.

    As always, much thanks for replies.
    Last edited by teamdad; Jun 13th, 2004 at 08:23 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width