Results 1 to 8 of 8

Thread: [RESOLVED] [2005] Key Enter problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    Resolved [RESOLVED] [2005] Key Enter problem

    I have a form and input txtbox. When I press enter I want to display a msgbox. But if the user press enter. The program gets stuck in repeating the msgbox. How do I stop this?

  2. #2
    Hyperactive Member josep's Avatar
    Join Date
    Sep 2006
    Location
    Barcelona
    Posts
    409

    Re: [2005] Key Enter problem

    show us your code otherwise we cannot help you
    Useful links:DB connection strings ADO.NET VB.NET Tutorials

    • Don't forget to close the thread if solved
    • If this post helps you rate it

  3. #3
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: [2005] Key Enter problem

    Set your Form's KeyPreview property to True and in your KeyPress event of the Form, have the following code:
    VB Code:
    1. If KeyAscii = 13 Then
    2.             msgbox "Your text goes here"
    3.         End If
    Microsoft Techie

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] Key Enter problem

    Show us your code so that we can help you find where and why you get stuck in the loop.

  5. #5
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [2005] Key Enter problem

    Quote Originally Posted by mnavas
    I have a form and input txtbox. When I press enter I want to display a msgbox. But if the user press enter. The program gets stuck in repeating the msgbox. How do I stop this?
    Hi,

    You can try this;

    VB Code:
    1. Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
    2.         If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
    3.             MsgBox("Your text goes here")
    4.         End If
    5.  
    6.     End Sub

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  6. #6
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Key Enter problem

    I tested this a bunch of times without getting stuck in any loops.

    VB Code:
    1. Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    2.         If e.KeyCode = Keys.Enter Then
    3.             MessageBox.Show("Hello There")
    4.         End If
    5.     End Sub
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    Re: [2005] Key Enter problem

    VB Code:
    1. Select Case e.KeyCode
    2.             Case Keys.Enter
    3.                 If DataSetp.Tables("workers").Rows.Count = 1 Then
    4.                     '
    5.                 Else
    6.                     MsgBox("Error", MsgBoxStyle.Critical, "Error")
    7.                 End If
    8.                 Mtxlogin.Text = String.Empty
    9. End Select

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    Resolved Re: [2005] Key Enter problem

    I found the error I use keyup event....instead of kepress... now is working fine.. thank to all.

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