Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 6th, 2003, 04:20 AM
Registered User
Join Date: Aug 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default textbox with numerical values

I'm looking for a window form textbox allowing to insert just floating point values, with 3 decimals.
I remember that in VB6 there was a property called data member witch was doing it.

Is there in C# something like that?

Could you suggest to me a tutorial or an HOWTO?

Thanks in advance! :)
Reply With Quote
  #2 (permalink)  
Old August 7th, 2003, 12:44 PM
Authorized User
Join Date: Jun 2003
Location: Gainesville, FL, USA.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts

My cheap $0.02:
I think you have two options.

1~ Validation of complete text in the text box.
Say you have the textbox tBox_1, and you will use whatever the user enters there when they click on button btn_1. Then, in the handler of the Click on btn_1 I'd perform the validation before doing anything else:
string s = tBox_1.Text;
bool b = isValidFloatingPoint(s);
  //Report issue via MessageBox or throw an Exception
//Do whatever you need to do.

2~ Intercept and handle the ChangedValue event of the tBox:
this even is triggered every time the text in the tBox is changed (such as when the user
enters a new value, or appends something).

I don't have much experience with the second option, since I usually end up using the first one.
Look at any chapter on Events and Delegates for mor einfo.
Also, you may look at the Regex class to quickly check if the input is a valid floating point.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
assign numerical values to text ptrussell2009 Excel VBA 9 October 8th, 2017 04:38 AM
Sum Textbox Values Snuffles ASP.NET 2.0 Basics 1 April 13th, 2007 01:36 PM
Taking values from textbox derekl ASP.NET 1.0 and 1.1 Professional 3 February 20th, 2006 08:30 AM
Getting Numerical Values Fiddleman HTML Code Clinic 2 September 13th, 2004 02:51 PM
How to extract numerical values from string? Genuine Beginning PHP 7 August 7th, 2004 07:49 AM

All times are GMT -4. The time now is 05:30 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.