473,836 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

isnumeric in c sharp

I have a pocket pc project in c#.

From a textbox i have to verify if the input is numeric. I have found
in the msdn a sample like this: textbox1.numeri c = true / false. But
this do not work in my environment.

If I convert the textbox content explicit to a numeric value, and is
is not numeric, the program ran into the error handler (try catch).
This is not what I want!

For example: 2 textbox, 1 button
If the user click the button, the program should proof if the content
of the textboxes is numeric, if not, it should use a standard value
and then go on.

A nice method like 'isnumeric' would be glad.

Thanks for all assistance.
Nov 15 '05
10 29281
At the least, I have to admit that the double.TryParse works well and is a 1
liner. Looking at the VB IsNumeric clone I posted above, it is much
simpler.

Thanks,
Shawn

"crowl" <cr***@gmx.de > wrote in message
news:e1******** *************** ***@posting.goo gle.com...
Thank you all for the nice ideas!

I think a own methode fits to my need.

Thanks again.

"Shawn B." <le****@html.co m> wrote in message

news:<#a******* *******@TK2MSFT NGP09.phx.gbl>. ..
This won't detect Hexadecimal values.
Thanks,
Shawn

"Dave Lech" <da*******@tyso n.com> wrote in message
news:e4******** ******@TK2MSFTN GP11.phx.gbl...
Here is some code that doesn't rely on error trapping:

public static bool IsNumeric(strin g stringToTest)

{

double newVal;

return double.TryParse (stringToTest, NumberStyles.An y,
NumberFormatInf o.InvariantInfo , out newVal);

}

"crowl" <cr***@gmx.de > wrote in message
news:e1******** *************** ***@posting.goo gle.com...
> I have a pocket pc project in c#.
>
> From a textbox i have to verify if the input is numeric. I have found > in the msdn a sample like this: textbox1.numeri c = true / false. But
> this do not work in my environment.
>
> If I convert the textbox content explicit to a numeric value, and is
> is not numeric, the program ran into the error handler (try catch).
> This is not what I want!
>
> For example: 2 textbox, 1 button
> If the user click the button, the program should proof if the content > of the textboxes is numeric, if not, it should use a standard value
> and then go on.
>
> A nice method like 'isnumeric' would be glad.
>
> Thanks for all assistance.

Nov 15 '05 #11

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

Similar topics

8
2325
by: eje | last post by:
IsNumeric(value) should return false if value "can not be successfully converted to a Double." Instead I get the following error message: "Input string was not in a correct format." I use the following function in a validating class to use when needed. (Value = H880118A gave the error (like other 'unconvertible' strings)) Public Function Numeric(ByVal value) As Boolean
4
13278
by: Eugene Anthony | last post by:
I have received the following feedback for the two functions bellow: "The ISNUMERIC test is WORTHLESS for checking for an INT value, because ISNUMERIC will happily accept DOUBLE values, such as 89.11998811777 and other values that are simply *NOT* INT values." <% function isZip(input)
14
40151
by: Kenny | last post by:
Hello, I would like to know if the function IsNumeric requires a header like #include <iostream> to be functionnal thanks ken
8
2615
by: John Bowman | last post by:
Hello, Does anyone have a good/reliable approach to implementing an IsNumeric() method that accepts a string that may represent a numerical value (eg. such as some text retrieved from an XML file)? Thus if you pass it "1" or "5.12345" it returns true, but "1b3q" it returns false? I know VB has this sort of function, but was wondering how to implement something similar in C#. I suppose I could use the Convert methods and catch any...
7
2387
by: Nathan Truhan | last post by:
All, I think I may have uncovered a bug in the IsNumeric function, or at least a misunderstanding on functionality. I am writing a Schedule Of Classes Application for our campus and have a section that lists the Times, Buildings and rooms for courses. In this section I have a function called PadCell that takes3 parameters, one the value, one a padd count and one a a boolean input called StripNumeric, that if true, checks if the value...
8
2591
by: moondaddy | last post by:
What's the .net framework equivalent of the vb function isnumeric? If there isn't one, how can I test a string variable to see if its a number or not? I don't want to use isnumeric if possible -- moondaddy@noemail.noemail
12
3068
by: sck10 | last post by:
Hello, I am trying to determine if a value is NOT numeric in C#. How do you test for "Not IsNumeric"? protected void fvFunding_ItemInserting_Validate(object sender, FormViewInsertEventArgs e) if (e.NewValues != "" && Not IsNumeric(e.NewValues)) {
12
1671
by: Paul | last post by:
Hi, I am trying to check a string to see if it's first 3 characters are numeric and if they are, to replace those 3 characters with something else. I've tried this but nothing happens... newname = Replace(newname, VB.Left(newname, 3) = "101-", "101. ")
17
2304
by: MLH | last post by:
I have tested the following in immed window: ?isnumeric(1) True ?isnumeric(1.) True ?isnumeric(1.2) True ?isnumeric(1.2.2)
0
9818
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
9668
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10589
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
9371
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
7790
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
6978
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
5825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4448
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
2
4015
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.