473,800 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1414
Private Sub TextBox1_KeyPre ss(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles TextBox1.KeyPre ss

If Char.IsLetter(e .KeyChar) Then

'OK

Else

'Not OK

e.Handled = True

End If

End Sub

OHM

"Jack" <an*******@disc ussions.microso ft.com> wrote in message
news:3E******** *************** ***********@mic rosoft.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*******@disc ussions.microso ft.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******** ******@tk2msftn gp13.phx.gbl...
* "=?Utf-8?B?SmFjaw==?=" <an*******@disc ussions.microso ft.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
3301
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 form or not, or even "sub classed" the form or check box. Is there a dll that was pre-loaded? All I can do is guess....
1
5021
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 "MyField1" is True. No problem, I just need to write "Expression is" and " = -1 "
7
3943
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 123.0000 123 i.e. I want to trim trailing zeros and (decimal point if no decimal values
3
4055
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
1539
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 shortdate. When inserted to SQL the datetimepicker format for the date is short. I have not had a problem with the formatting of a date to a textbox before, but this time I am using the CurrencyManager to navigate though several records. This is...
2
2355
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 on. I have a second table that contains a list of tasks to be performed and relates to the Case_List through a Case_ID. So currently, I can bring up a form that has a list of all my cases, I can then select a case and it opens a new form that...
4
2932
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 of repetitive codeing. Is there a way possible to globally format the textboxes both on the .validate function, as well as when the enter key is pressed. Any suggestions or examples wouldbe very usefull, as i have a loads of these data forms...
4
8980
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 textbox background to display yellow, else I want it to be just white. Here's my code... but it is not working Private Sub Form_Load() If Me!STATUS = "Inactive" Then Me!STATUS.BackColor = RGB(255, 255, 0) Else
2
3323
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 current value, I set its background color. No problem with this part. My problem is that when clicking different text boxes representing the records on the continuous form, the left and the right margin areas do not always take on the background...
1
2555
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 correct, and is working fine. Using Conditional Formatting for this textbox, I attempt to change the
0
9695
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10514
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10287
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10260
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9099
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7588
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2956
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.