Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
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 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 August 6th, 2003, 04:20 AM
Registered User
Join Date: Aug 2003
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! :)
Old August 7th, 2003, 12:44 PM
Authorized User
Join Date: Jun 2003
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.


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

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