HighTechTalks DotNet Forums  

Text Input Question

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss Text Input Question in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jerry
 
Posts: n/a

Default Text Input Question - 05-15-2007 , 06:14 PM






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

Reply With Quote
  #2  
Old   
pvdg42
 
Posts: n/a

Default Re: Text Input Question - 05-16-2007 , 09:03 AM







"Jerry" <Jerry (AT) discussions (DOT) microsoft.com> wrote

Quote:
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




Reply With Quote
  #3  
Old   
Jerry
 
Posts: n/a

Default Re: Text Input Question - 05-16-2007 , 03:45 PM



This will probably work if I wanted a button to click, but how about entering
114 in the textbox and using the enter key. I'm familiar with show and Hide
and the messagebox.
Thanks,
Jerry

"pvdg42" wrote:

Quote:
"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




Reply With Quote
  #4  
Old   
Jerry
 
Posts: n/a

Default Re: Text Input Question - 05-16-2007 , 04:01 PM



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

End If
End Sub

"pvdg42" wrote:

Quote:
"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




Reply With Quote
  #5  
Old   
pvdg42
 
Posts: n/a

Default Re: Text Input Question - 05-16-2007 , 11:39 PM




"Jerry" <Jerry (AT) discussions (DOT) microsoft.com> wrote

Quote:
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("...")
Quote:
End If
End Sub

Assuming you mean to use it to signal an incorrect code...
See above.




Reply With Quote
  #6  
Old   
Jerry
 
Posts: n/a

Default Re: Text Input Question - 05-17-2007 , 12:19 AM



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

"pvdg42" wrote:

Quote:
"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.




Reply With Quote
  #7  
Old   
pvdg42
 
Posts: n/a

Default Re: Text Input Question - 05-17-2007 , 07:48 AM




"Jerry" <Jerry (AT) discussions (DOT) microsoft.com> wrote

Quote:
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
event procedure. That event fires when the textbox is exited by the user.




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.