Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

submit value in winform using Enter Button

Posted on 2006-07-20
4
Medium Priority
?
403 Views
Last Modified: 2012-05-05
Hi,

am using vb.net  2003, having 1 question on submitting information

i have 1 text box accepting UPC number " 000000000000 " 

1 - i need to validate this input as soon as user press enter ( validation in this case mean no alphabets or any other special character and length must be lets say 12 in this case.)


2 -need to submit this information after validation o lets say SP in sql 2000

i am not sure how i can do all that on enter event .


Regards
SMB

0
Comment
Question by:bsheikh
  • 3
4 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17146120
use javascript onKeyPress when e=13
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17146121
oops, you can't use javascript with winforms
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17146148
Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
 
          If e.KeyChar = CChar(13) Then
 
              ''validate input here
 
          End If
 
     End Sub 'OnKeyPress
 
0
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 400 total points
ID: 17146322
  Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Enter Then
            If Not IsNumeric(TextBox1.Text) AndAlso TextBox1.Text.Length <> 12 Then
                MsgBox("Invalid Entry")
                Exit Sub
            Else
                'Perform SQL Commands here
            End If
        End If
    End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question