Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

If a value is non numeric?

Posted on 2008-06-17
7
Medium Priority
?
262 Views
Last Modified: 2013-12-16
If Price is nonnumeric then
   Price = 0.00;

double Price;

How do I check for non numeric.
0
Comment
Question by:mathieu_cupryk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 21807443
check out the TryParse() function, is available on the numerical data types:
http://blog.redditech.com/professional/difference-between-intparse-and-converttoint32-in-c/
0
 
LVL 18

Expert Comment

by:Joel Coehoorn
ID: 21807520
If price is defined as a double, then price *is* numeric.  No need to check anything.
0
 

Author Comment

by:mathieu_cupryk
ID: 21807584
say it has a value of 'a'
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 27

Expert Comment

by:VBRocks
ID: 21807593
Here's an example of using the TryParse() method that angellll intended you to see.  If it helps you,
credit angellll.

        Dim price As String = ""   'Non numeric

        Dim dPrice As Double
        Double.TryParse(price, dPrice)

        MsgBox(dPrice.ToString())

       
0
 
LVL 18

Expert Comment

by:Joel Coehoorn
ID: 21807645
From your original post:
 >      double Price;

If Price is defined like that, it will _never_ have a value of 'a'.   A variable defined as a double cannot hold strings.
0
 
LVL 1

Expert Comment

by:CartoonHead
ID: 21807675
Unless the value is gathered as a string and is to be assigned to a double... in which case TryParse() would be good.

I think maybe the question is a little too vague.
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 21808128
Abour VBRocks example: in VBN it's possible to use IsNumeric function. Really, it is possible to to import Microsoft.VisualBasic namespace in C# and use the function in C# (not really recommended).

Read good discussion and explanation of number of approaches you may use:

http://www.codeproject.com/KB/cs/csharp-isnumeric.aspx
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question