473,396 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How To Program Textbox Input Event?

Using VB express, I have a textbox in a form and want to ask the user to
input a number , If the number is 114, then I want to do a form2.show
/me.hide so the form2 comes up, but if they put in the wrong number then a
messagebox comes up and says, you entered a wrong number. Can anyone help me
with this code?
Thanks,
Jerry

May 16 '07 #1
7 1520
In the Leave event handler of the text box:

Dim f2 As Form2
If (TextBox1.Text = "114") Then
f2 = New Form2()
Me.Hide()
f2.Show()
Else
MessageBox.Show ("Invalid Number")
End If

"Jerry" wrote:
Using VB express, I have a textbox in a form and want to ask the user to
input a number , If the number is 114, then I want to do a form2.show
/me.hide so the form2 comes up, but if they put in the wrong number then a
messagebox comes up and says, you entered a wrong number. Can anyone help me
with this code?
Thanks,
Jerry
May 16 '07 #2
I don't get this, I want to leave the form to another form if I put 114 in
the textbox and press the enter key.
Thanks,
Jerry

"Siva M" wrote:
In the Leave event handler of the text box:

Dim f2 As Form2
If (TextBox1.Text = "114") Then
f2 = New Form2()
Me.Hide()
f2.Show()
Else
MessageBox.Show ("Invalid Number")
End If

"Jerry" wrote:
Using VB express, I have a textbox in a form and want to ask the user to
input a number , If the number is 114, then I want to do a form2.show
/me.hide so the form2 comes up, but if they put in the wrong number then a
messagebox comes up and says, you entered a wrong number. Can anyone help me
with this code?
Thanks,
Jerry
May 16 '07 #3
The following code works, but where do I put the messagebox.show statement so
it still works?
Thanks,
Jerry

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

"Siva M" wrote:
In the Leave event handler of the text box:

Dim f2 As Form2
If (TextBox1.Text = "114") Then
f2 = New Form2()
Me.Hide()
f2.Show()
Else
MessageBox.Show ("Invalid Number")
End If

"Jerry" wrote:
Using VB express, I have a textbox in a form and want to ask the user to
input a number , If the number is 114, then I want to do a form2.show
/me.hide so the form2 comes up, but if they put in the wrong number then a
messagebox comes up and says, you entered a wrong number. Can anyone help me
with this code?
Thanks,
Jerry
May 16 '07 #4
Code needs minor modification (swap the If conditions) to accomodate the
MessageBox.Show:

If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
If (TextBox1.Text = "114") Then
mcc114.Show()
Me.Hide()
Else
MessageBox.Show ("Invalid number")
End If
End If
"Jerry" wrote:
The following code works, but where do I put the messagebox.show statement so
it still works?
Thanks,
Jerry

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

"Siva M" wrote:
In the Leave event handler of the text box:

Dim f2 As Form2
If (TextBox1.Text = "114") Then
f2 = New Form2()
Me.Hide()
f2.Show()
Else
MessageBox.Show ("Invalid Number")
End If

"Jerry" wrote:
Using VB express, I have a textbox in a form and want to ask the user to
input a number , If the number is 114, then I want to do a form2.show
/me.hide so the form2 comes up, but if they put in the wrong number then a
messagebox comes up and says, you entered a wrong number. Can anyone help me
with this code?
Thanks,
Jerry
>
May 17 '07 #5
The message box does not come up when I input a code of say 112
Thanks,
Jerry

"Siva M" wrote:
Code needs minor modification (swap the If conditions) to accomodate the
MessageBox.Show:

If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
If (TextBox1.Text = "114") Then
mcc114.Show()
Me.Hide()
Else
MessageBox.Show ("Invalid number")
End If
End If
"Jerry" wrote:
The following code works, but where do I put the messagebox.show statement so
it still works?
Thanks,
Jerry

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

"Siva M" wrote:
In the Leave event handler of the text box:
>
Dim f2 As Form2
If (TextBox1.Text = "114") Then
f2 = New Form2()
Me.Hide()
f2.Show()
Else
MessageBox.Show ("Invalid Number")
End If
>
"Jerry" wrote:
>
Using VB express, I have a textbox in a form and want to ask the user to
input a number , If the number is 114, then I want to do a form2.show
/me.hide so the form2 comes up, but if they put in the wrong number then a
messagebox comes up and says, you entered a wrong number. Can anyone help me
with this code?
Thanks,
Jerry
May 17 '07 #6
This logic will validate the number only after your press the Enter key. It
will not pop up the message box as type in 112.

I tried the code and it does work.

"Jerry" wrote:
The message box does not come up when I input a code of say 112
Thanks,
Jerry

"Siva M" wrote:
Code needs minor modification (swap the If conditions) to accomodate the
MessageBox.Show:

If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
If (TextBox1.Text = "114") Then
mcc114.Show()
Me.Hide()
Else
MessageBox.Show ("Invalid number")
End If
End If
"Jerry" wrote:
The following code works, but where do I put the messagebox.show statement so
it still works?
Thanks,
Jerry
>
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
>
"Siva M" wrote:
>
In the Leave event handler of the text box:

Dim f2 As Form2
If (TextBox1.Text = "114") Then
f2 = New Form2()
Me.Hide()
f2.Show()
Else
MessageBox.Show ("Invalid Number")
End If

"Jerry" wrote:

Using VB express, I have a textbox in a form and want to ask the user to
input a number , If the number is 114, then I want to do a form2.show
/me.hide so the form2 comes up, but if they put in the wrong number then a
messagebox comes up and says, you entered a wrong number. Can anyone help me
with this code?
Thanks,
Jerry
>
May 17 '07 #7
Thank you
I entered your code wrong, your right it works, thanks again
Jerry

"Siva M" wrote:
This logic will validate the number only after your press the Enter key. It
will not pop up the message box as type in 112.

I tried the code and it does work.

"Jerry" wrote:
The message box does not come up when I input a code of say 112
Thanks,
Jerry

"Siva M" wrote:
Code needs minor modification (swap the If conditions) to accomodate the
MessageBox.Show:
>
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
If (TextBox1.Text = "114") Then
mcc114.Show()
Me.Hide()
Else
MessageBox.Show ("Invalid number")
End If
End If
>
>
"Jerry" wrote:
>
The following code works, but where do I put the messagebox.show statement so
it still works?
Thanks,
Jerry

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

"Siva M" wrote:

In the Leave event handler of the text box:
>
Dim f2 As Form2
If (TextBox1.Text = "114") Then
f2 = New Form2()
Me.Hide()
f2.Show()
Else
MessageBox.Show ("Invalid Number")
End If
>
"Jerry" wrote:
>
Using VB express, I have a textbox in a form and want to ask the user to
input a number , If the number is 114, then I want to do a form2.show
/me.hide so the form2 comes up, but if they put in the wrong number then a
messagebox comes up and says, you entered a wrong number. Can anyone help me
with this code?
Thanks,
Jerry
May 17 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jerry | last post by:
In limiting textbox input to 500 characters I would like to include a dynamic count of characters input while the user is typing into a textbox. This would obviously be a client side control,...
14
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user...
1
by: alex23 | last post by:
Hey everyone, I've just started looking at Wax and have hit a problem I can't explain. I want an app to respond to every character input into a TextBox. Here's a simple, working example: ...
0
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the...
69
by: raylopez99 | last post by:
They usually don't teach you in most textbooks I've seen that delegates can be used to call class methods from classes that are 'unaware' of the delegate, so long as the class has the same...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.