VB.Net: Check if currency

i am using vb.net,

how to check if a value is in currency format or is a currency.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Where is the value? In a string variable, textbox, datagridview ...?
baabaa_nlAuthor Commented:
value from a datagridviewcell
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

use Regex.IsMatch("RegularExpression") to match the value.

Use the regular expression used in my above link
You can call this method on any Datagrid event which you feel is suitable after databinding event....
käµfm³d 👽Commented:
You should be able to use something like Decimal.TryParse, supplying the appropriate parameters. In this way, you won't have to do any special coding if your code moves to machine where the format is £2,00 (and your development machine is set up as $2.00).

For example:

Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
    Dim provider As IFormatProvider = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat
    Dim d As Decimal

    Me.lblResult.Text = Decimal.TryParse(Me.txtInput.Text, Globalization.NumberStyles.Currency, provider, d)
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:

The last parameter to Decimal.TryParse is passed ByRef, so if the call to TryParse succeeds, then the converted value will be stored in "d" (in my example). TryParse itself returns a boolean value indicating whether or not the value being tested could be converted to a Decimal type.
datagridviewcell does not store values in currency (either string, decimal, double etc) you can parse the value in the cell to check it is numeric, e.g IsNumeric(Me.DataGridView1.Item(0).Value.ToString)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.