|
-
Nov 8th, 2006, 07:50 AM
#1
Thread Starter
Addicted Member
[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?
-
Nov 8th, 2006, 07:54 AM
#2
Hyperactive Member
Re: [2005] Key Enter problem
show us your code otherwise we cannot help you
-
Nov 8th, 2006, 08:08 AM
#3
Fanatic Member
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:
If KeyAscii = 13 Then
msgbox "Your text goes here"
End If
-
Nov 8th, 2006, 10:09 AM
#4
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.
-
Nov 8th, 2006, 11:04 AM
#5
Re: [2005] Key Enter problem
 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:
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
MsgBox("Your text goes here")
End If
End Sub
Wkr,
sparrow1
-
Nov 8th, 2006, 11:29 AM
#6
Re: [2005] Key Enter problem
I tested this a bunch of times without getting stuck in any loops.
VB Code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
MessageBox.Show("Hello There")
End If
End Sub
-
Nov 8th, 2006, 01:40 PM
#7
Thread Starter
Addicted Member
Re: [2005] Key Enter problem
VB Code:
Select Case e.KeyCode
Case Keys.Enter
If DataSetp.Tables("workers").Rows.Count = 1 Then
'
Else
MsgBox("Error", MsgBoxStyle.Critical, "Error")
End If
Mtxlogin.Text = String.Empty
End Select
-
Nov 8th, 2006, 01:47 PM
#8
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|