![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
using VB express, I have a textbox1.text on the form, If someone enters 114 and presses the enter key, then I want it to show another form/hide current form, if they enter any other number then I want a message show to tell them they have entered a incorrect number, can anyone help me with this? Thanks, Jerry |
#3
| |||
| |||
|
|
"Jerry" <Jerry (AT) discussions (DOT) microsoft.com> wrote in message news:A5217471-0FDB-460F-9E70-9078A35532BD (AT) microsoft (DOT) com... using VB express, I have a textbox1.text on the form, If someone enters 114 and presses the enter key, then I want it to show another form/hide current form, if they enter any other number then I want a message show to tell them they have entered a incorrect number, can anyone help me with this? Thanks, Jerry Read up on the Visible property, and the show() and hide() methods. http://msdn2.microsoft.com/en-us/lib...de(VS.71).aspx http://msdn2.microsoft.com/en-us/lib...ow(VS.71).aspx Roughly like this (in a method that responds to a click on a button on Form1) Private Sub btnCode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCode.Click If txtCode.Text = "114" Then Form2.Show() Me.Hide() Else MessageBox.Show("Code is incorrect!") txtCode.Focus() txtCode.SelectAll() End If End Sub |
#4
| |||
| |||
|
|
"Jerry" <Jerry (AT) discussions (DOT) microsoft.com> wrote in message news:A5217471-0FDB-460F-9E70-9078A35532BD (AT) microsoft (DOT) com... using VB express, I have a textbox1.text on the form, If someone enters 114 and presses the enter key, then I want it to show another form/hide current form, if they enter any other number then I want a message show to tell them they have entered a incorrect number, can anyone help me with this? Thanks, Jerry Read up on the Visible property, and the show() and hide() methods. http://msdn2.microsoft.com/en-us/lib...de(VS.71).aspx http://msdn2.microsoft.com/en-us/lib...ow(VS.71).aspx Roughly like this (in a method that responds to a click on a button on Form1) Private Sub btnCode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCode.Click If txtCode.Text = "114" Then Form2.Show() Me.Hide() Else MessageBox.Show("Code is incorrect!") txtCode.Focus() txtCode.SelectAll() End If End Sub |
#5
| |||
| |||
|
|
the following code works, but does not have the messagebox.show command in it, where do I put it so it works? Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If TextBox1.Text = "114" Then If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then mcc114.Show() Me.Hide() End If Else |
|
End If End Sub Assuming you mean to use it to signal an incorrect code... |
#6
| |||
| |||
|
|
"Jerry" <Jerry (AT) discussions (DOT) microsoft.com> wrote in message news:CC94EBCD-45CA-46F5-ABA2-C0EF8BAD0C48 (AT) microsoft (DOT) com... the following code works, but does not have the messagebox.show command in it, where do I put it so it works? Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If TextBox1.Text = "114" Then If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then mcc114.Show() Me.Hide() End If Else MessageBox.Show("...") End If End Sub Assuming you mean to use it to signal an incorrect code... See above. |
#7
| |||
| |||
|
|
OK this was my initial problem, here's what happens with the code, I enter a 1, it immediately shows the message box, then I have to click ok in message box, then I can enter a 1, then message box comes up, then I can enter a 4, then it executes the program . I want to be able to enter 114, without message box commng up each time (until I put three numbers in and hit enter) Thanks, Jerry Ah, I missed the event you are using. You want to put your code in the leave |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |