473,813 Members | 4,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capture and Identify User Input

If a Window's form contains two textboxes, txtUserName for names and the
other txtDimension for mathematical values, how could the program code
be set up to identify that only letter character(s) are entered into
txtUserName .... and that only numbers and decimals are entered into
txtDimension ?

Secondly, how could the program code be set up to inform the user that the
wrong type of data was entered ?

All constructive suggestions are welcome.

Dennis
Nov 15 '05 #1
1 1791
Dennis wrote:
If a Window's form contains two textboxes, txtUserName for names and
the other txtDimension for mathematical values, how could the program
code be set up to identify that only letter character(s) are entered into txtUserName .... and that only numbers and decimals are entered into
txtDimension ?
The System.Text.Reg ularExpressions .Regex class will handle this quite
nicely:

Regex.IsMatch(< someString>, "([a-zA-Z]+)") will return false if the
supplied string does not consist solely of alphabetic characters.

Regex.IsMatch(< string>, "([0-9]+).") will return false if the supplied
string does not consist solely of numeric characters with an optional
decimal.
Secondly, how could the program code be set up to inform the user
that the wrong type of data was entered ?


You can either perform the checking when they press an OK or Submit
button or you can handle the TextChanged event and perform the checking
as the user enters the values. In either case, just throw up a MessagBox
alerting then to the problem.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #2

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

Similar topics

8
2868
by: George Hester | last post by:
When the address bar is highligted? That is nothing on the page is selected. The address bar is selected. Capture keydown or keypress? Any ideas using javascript? Thanks. -- George Hester __________________________________
8
487
by: DraguVaso | last post by:
Hi, I want my application do different actions depending on the exception it gets. For exemple: I have an SQL-table with a unique index. In case I try to Insert a record that's alreaddy in it I get this exception: "Cannot insert duplicate key row in object 'tblTelephones' with unique index 'UniqueValues'." What I'm looking for is a way to identify the exception: in case I get this
2
3143
by: Paresh Shah | last post by:
Hi Friends... I have an query on how to capture onFocus event for all the input controls without writing onFocus event in the <input> tag. say my html form has 3 or 4 or 5 input text boxes, now I want to capture onFocus event for all the text boxes without writing onFocus code in <input> tag.
5
3783
by: Chris | last post by:
I want to capture a users windows login Id and display it in asp.net web page (using VB.net). Any and all suggestions accepted.. A code snippet wud be really appreciated. Read an article in MSDN (LDAP), but cud'nt make it working.
2
5035
by: TC | last post by:
Hello, I need to build a very simple text editor. The requirement is that the input screen should be divided into 'm*n' cells ('m' rows, 'n' columns, with each cell of a fixed size). Whenever the user wants to input text, he will click on one of these cells, and then enter the text. The text should then be visible inside the cell. From my very limited knowledge of VB, I plan to use the 'group box' construct to denote one cell. Now,...
6
2368
by: trbjr | last post by:
Hello experts, I want to describe a project design and then ask some questions at the end. There is no code in this discussion, just symbols to illustrate an idea. Let S stand for a screen or form. I want to capture data as answers to questions presented to a user thru a series of screens. Since there are many user questions, I will ask them thru a series of screens. Thus, let S1, S2, S3, ... Sn
11
7394
by: Randy | last post by:
I have a MonthCalendar on one of my forms. I have disovered that the DateChanged event is triggered not only when the user clicks on a new date, but also if they click on the Previous or Next Month arrows (meaning they click on either of the left or right pointing arrows in the top corner). If the user changes the month, it messes up some of the date logic that I have in the DateChanged event. Does anybody know how I can capture this...
9
1630
by: dudelideisann | last post by:
Hi! I have a form where the user enters some input. The input will eventionally become a database table. When he hit the 'submit' button the info is put into an array and then into a session variable for later. The session gets it's name from the user inputfield 'tablename' .. Then, if the user wants to he can then proceed to 'checkout.php' or he can make a new input in another form and hit the submit button again. The same will happen...
2
5043
by: ekasII | last post by:
I'm trying to capture text input by user to file, password = wx.TextCtrl(self.panel_1,wx.ID_ANY,pos=(230,150),size=(200,20),style= wx.TE_PASSWORD) l__password_file = <path\file.txt> l__get_password = password.GetLineText(1) l__write_password = open(l__password_file,'w').write(l__get_password) Somehow, GetLineText(1) does not capture the user input, it is suppose to return text on line 1, which must be the user input password, but it does...
0
9734
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
10665
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...
1
10420
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
9221
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...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
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...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
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.