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

Formatting TextBox ?

Hell
I have a few text boxes on my form and I need in one to allow only numbers and on the other only letters how to enforce that you can't enter numbers in a letters textbox and...
Jack
Nov 20 '05 #1
5 1398
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If Char.IsLetter(e.KeyChar) Then

'OK

Else

'Not OK

e.Handled = True

End If

End Sub

OHM

"Jack" <an*******@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
Hello
I have a few text boxes on my form and I need in one to allow only numbers and on the other only letters how to enforce that you can't enter numbers in
a letters textbox and... Jack

Nov 20 '05 #2
* "=?Utf-8?B?SmFjaw==?=" <an*******@discussions.microsoft.com> scripsit:
I have a few text boxes on my form and I need in one to allow only
numbers and on the other only letters how to enforce that you can't
enter numbers in a letters textbox and...


Instead of resticting the type of input, I would add code to the
control's 'Validating' event and set an ErrorProvider to make the user
aware of the invalid input. That's more user-friendly because you do
not forbid the user to do editing pasted text from the clipboard
etc. inside the textboxes.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3

granted!

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl...
* "=?Utf-8?B?SmFjaw==?=" <an*******@discussions.microsoft.com> scripsit:
I have a few text boxes on my form and I need in one to allow only
numbers and on the other only letters how to enforce that you can't
enter numbers in a letters textbox and...


Instead of resticting the type of input, I would add code to the
control's 'Validating' event and set an ErrorProvider to make the user
aware of the invalid input. That's more user-friendly because you do
not forbid the user to do editing pasted text from the clipboard
etc. inside the textboxes.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #4
Hi Jack,

I would take that nice piece of code from OHM and that what Herfried stated.

I think it is nicer that a user gets direct a signal when he is typing and
not after he had done a lot.

If you take the validate than, you prevent than all other things in one
time.

Just my thought

Cor
Nov 20 '05 #5
* "One Handed Man \( OHM#\)" <news.microsoft.com> scripsit:
granted!


LOL!

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6

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

Similar topics

4
by: cefrancke | last post by:
How does Stephen Lebans make the datasheet row color change by clicking a row's check box field? I cant find any code associated with the form, and I cant tell if you have created a class on the...
1
by: GGerard | last post by:
Hello Is there a way to use a variable in the Conditional Formatting of a Textbox? Example : I want the background of a textbox in a continuous form to change color when the value of...
7
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34...
3
by: trint | last post by:
Ok, I have a textbox that I want to check as one types each charactor for Currency formatting, another one for Date formating. Any help is appreciated. Thanks, Trint
2
by: Thomas Beyerlein | last post by:
I am binding dates to a textbox, the date is stored in SQL in a datetime field. When it gets bound it turns it into a long date (Sunday, Dec. 25 2005), in SQL when viewing the table it views as a...
2
by: jodyblau | last post by:
I'm not certain that what I am trying to do is possible; in any event I haven't been able to figure it out. Here is what I am trying to do: I have one table that has a list of cases I'm working...
4
by: Peter Newman | last post by:
the data input app im writing has some 30 + input fields and i want to be able to format them. I know i can use the .validate on each textbox and format the 'string' however this require loads...
4
by: slinky | last post by:
Thanks in advance... I have a continuous style form with a field for each record called "STATUS". I simply want to have the form load and if the value of the textbox is "Inactive" I want the...
2
by: robertng90025 | last post by:
I'm having a problem with MS Access 2003 and its conditional formatting. I have textboxes on a continuous form whose left and right margins are set to 0.03 inches. Based on each textbox's...
1
by: Greg (codepug | last post by:
Access 2000 Using a textbox of a single form, I created a calculated field. The following code is in the Control Source for this field: =IIf(=24,+(/),/ ) The numbers that are calculated are...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.