473,399 Members | 3,603 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,399 software developers and data experts.

Insert key press in text box

Hi all

I am making a program whereby when the insert key is pressed in a text
box it opens up another form with the search parameters they entered in
the text box and automatically searches for the data. I have the code
below however it does not work when i press the insert key. I have
tried it with the enter key Ascii code 13 and all works fine! Is it
something to do with Insert being a system/bios key? My code is below;

Private Sub TelephoneTxt_KeyPress(ByVal sender As Object, ByVal e
As System.Windows.Forms.KeyPressEventArgs) Handles
TelephoneTxt.KeyPress
'handle telphone number search
Dim key As Char = Microsoft.VisualBasic.ChrW(45)
If e.KeyChar = key And TelephoneTxt.Text = "" And
SurnameTxt.Text = "" Then
MsgBox("Please enter at least one of the two search
parameters")
ElseIf e.KeyChar = key Then
CustomerSearch.ShowDialog()
CustomerSearch.CustomerReservationSearch(SurnameTx t.Text,
TelephoneTxt.Text)
End If
End Sub
Any help is much appreciated

Thanks

James

Dec 5 '06 #1
3 3352
"jimmy" <ja**************@tiscali.co.ukwrote in message
news:11*********************@16g2000cwy.googlegrou ps.com...
Hi all

I am making a program whereby when the insert key is pressed in a text
box it opens up another form with the search parameters they entered in
the text box and automatically searches for the data. I have the code
below however it does not work when i press the insert key. I have
tried it with the enter key Ascii code 13 and all works fine! Is it
something to do with Insert being a system/bios key? My code is below;

Private Sub TelephoneTxt_KeyPress(ByVal sender As Object, ByVal e
As System.Windows.Forms.KeyPressEventArgs) Handles
TelephoneTxt.KeyPress
'handle telphone number search
Dim key As Char = Microsoft.VisualBasic.ChrW(45)
If e.KeyChar = key And TelephoneTxt.Text = "" And
SurnameTxt.Text = "" Then
MsgBox("Please enter at least one of the two search
parameters")
ElseIf e.KeyChar = key Then
CustomerSearch.ShowDialog()
CustomerSearch.CustomerReservationSearch(SurnameTx t.Text,
TelephoneTxt.Text)
End If
End Sub
Any help is much appreciated

Thanks

James
James,

The KeyPress event doesn't fire for the insert key, as it doesn't produce a
character (e.KeyChar).
You can use the KeyDown or KeyUp event to trap the Insert key;

Private Sub TelephoneTxt_KeyDown(ByVal sender As Object, ByVal e As System.
_
Windows.Forms.KeyEventArgs) Handles TelephoneTxt.KeyDown
' Handle telphone number search
If e.KeyCode = Keys.Insert And TelephoneTxt.Text = "" And
SurnameTxt.Text = "" Then
MsgBox("Please enter at least one of the two search parameters")
ElseIf e.KeyCode = Keys.Insert Then
CustomerSearch.ShowDialog()
CustomerSearch.CustomerReservationSearch(SurnameTx t.Text,
TelephoneTxt.Text)
End If
End Sub

Hope that helps.
_____________________________
The Grim Reaper
Dec 5 '06 #2
On 5 Dec 2006 12:12:27 -0800, jimmy wrote:
Private Sub TelephoneTxt_KeyPress(ByVal sender As Object, ByVal e
As System.Windows.Forms.KeyPressEventArgs) Handles
TelephoneTxt.KeyPress
'handle telphone number search
Dim key As Char = Microsoft.VisualBasic.ChrW(45)
If e.KeyChar = key And TelephoneTxt.Text = "" And
SurnameTxt.Text = "" Then
MsgBox("Please enter at least one of the two search
parameters")
ElseIf e.KeyChar = key Then
CustomerSearch.ShowDialog()
CustomerSearch.CustomerReservationSearch(SurnameTx t.Text,
TelephoneTxt.Text)
End If
End Sub

Any help is much appreciated

Thanks

James
Hey james,

Try the KeyDown event instead

--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 5 '06 #3
Thanks to both you guys!

Dec 5 '06 #4

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

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
7
by: Paul Gorodyansky | last post by:
Hi, Say I have a text in my TEXTAREA box - 01234567890 I want - using script - insert say "abc" in the middle. Works almost OK in Internet Explorer (with one problem) based on their example...
5
by: Gunnar Kristiansen | last post by:
Hi! I have a form page which I am using as a frontend for my MySql database (for writing news). I do miss the functionality of a few buttons that could help me insert HTML tags etc, into my main...
1
by: tshad | last post by:
I can't seem to get insert into a DataGrid to work. I am using an example from the net and made changes to work on my computer. The grid comes up fine. The edit boxes in the footer are there. ...
0
by: Brenton Garman | last post by:
First off, I want to thank you for so speedily answering my question, (Mike and R.Mac) however, let me rephrase my question: "Upon startup, I need the textbox, without the user pressing the...
1
by: Chris | last post by:
I have a formview based on an SQL Data Source see below. I have a formview bound to it. The item insert template has a command button with a command name insert. When I press it the insert doesn't...
3
by: Mukesh | last post by:
sir, i am developing a database, which will store the users profile both personal and professional which includes the address, telephone, gender and etc. in my main table i have created a column...
2
by: stamyo | last post by:
Hello to everyone, i'm facing the following problem: I have a form which is used for both insert or update data.. The situation is like that: when the user fills the form, press the submit button...
1
by: skanemupp | last post by:
in this program when using the "c"-button it deletes the last token entered. i want to delete the token after the mousecursor. lets say the string is: 12*(81**.5+12) and i put the cursor between...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.