Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > BOOK: Beginning Visual C#
|
BOOK: Beginning Visual C#
This is the forum to discuss the Wrox book Beginning Visual C#, Revised Edition of Beginning C# for .NET v1.0 by Karli Watson, David Espinosa, Zach Greenvoss, Jacob Hammer Pedersen, Christian Nagel, Jon D. Reid, Matthew Reynolds, Morgan Skinner, Eric White; ISBN: 9780764543821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2004, 10:16 AM
Registered User
 
Join Date: Dec 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to guyhuang
Default Chapter 13 eg. TextBoxTest age TextBox changed

follow the code on the book we can build a program which can avoid typing wrong messages.
but the age TextBox has some problems.
if you type the ALL-RIGHT messages in each TextBox and then post some words in the age TextBox using the right click menu, it's OK.
so we get:
Code:
Name:Guyhuang
Address:Wuhan,
Hubei,
China.
Occupation:Programmer
Age:Programmer
the false is the function txtBox_TextChanged(object sender, EventArgs e).
we must check the changed text in txtAge TextBox to see if it is still a number.
but HOW.

i am a c# programmer learner in china.
hope to communicate with you.
 
Old January 22nd, 2004, 10:28 AM
Registered User
 
Join Date: Dec 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to guyhuang
Default

i found a way to solve this problem but is not very suitable.
if we can check string as a number, code will be simple.
that's code adding before the else in the function private void txtBox_TextChanged(object sender, EventArgs e)

Code:
            else if(tb==txtAge)//if tb==txtAge,avoiding any char that isnot num
            {
                char[] charArray;
                charArray=tb.Text.ToCharArray();
                bool isNum=true;
                foreach(char c in charArray)
                {
                    if(c<48||c>57)
                        isNum=false;
                }
                if(isNum==false)
                {
                    tb.Tag=false;
                    tb.BackColor=Color.Red;
                }
            }
i am a c# programmer learner in china.
hope to communicate with you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 bwoll BOOK: Beginning Access 2003 VBA 1 June 7th, 2007 03:57 PM
Remove value of dropdown list when textbox changed sn00pyg4rfi3ld Javascript How-To 1 January 20th, 2005 07:08 AM
Chapter 13 ElMorenito BOOK: Beginning ASP 3.0 0 January 14th, 2005 02:56 PM
using textbox keypress/text changed bazookajoe76 C# 5 October 10th, 2004 12:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.