473,386 Members | 1,841 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,386 software developers and data experts.

Textbox input restriction on the Keypressed event procedure

8
Hi mates,

I have written the code below on VB 2005 to try and restrict input on a textbox.
This code works very well on VB 2005 and its controls.

However my project's User interface (controls) are developed using Microsoft expression Blend and then I import the interface on VB 2005 and start coding.
Everything works well, however the code below does not work simply because the keyPress event is not available for my User interface.
So I'm wondering where else I can put the code below, or anything that might help.

Expand|Select|Wrap|Line Numbers
  1. Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  2.  
  3.     Dim num As String = TextBox1.Text
  4.     If IsNumeric(e.KeyChar) And num.Length < 10 Then
  5.         e.Handled = False
  6.     ElseIf AscW(e.KeyChar) = 8 Then
  7.         e.Handled = False
  8.     Else
  9.         e.Handled = True
  10.     End If
  11. End Sub
Oct 6 '07 #1
0 1699

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joe Su | last post by:
Is there a way to make a control based on Windows.Forms.TextBox, and it has a TextChanging event fired before Text property value change. otherwise there are two properties in the event args 1....
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,...
5
by: PD | last post by:
The TextChanged event is not being called when I hit the "Enter" key. Yet it does for the "Tab" key. I set a break point in the Page_Load event and the TextChanged event and none of these get...
7
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
2
by: active | last post by:
I have a picturebox usercontrol sitting on a usercontrol. I need a KeyPress event in the PictureBox. I suppose I could have a property in the pictureBox that is accessed by a call in a...
4
by: Tim Osborne | last post by:
Hi At first blush this seemed like it should be so simple. Guess again. I want to only allow numeric characters and hexadecimal values in a TextBox, anything else should be ignored, and maybe...
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...
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...
2
by: =?Utf-8?B?SmVycnkgSg==?= | last post by:
Hello, I am using asp.net 2003 using C#. I am creating textboxes dynamically and want to validate to make sure the user can only input an integer. I don't think I can use the validators...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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,...

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.