Solved

If a value is non numeric?

Posted on 2008-06-17
7
252 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
7 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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:jcoehoorn
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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:jcoehoorn
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 29

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now