Double.TryParse

  • Thread starter Thread starter Steffan A. Cline
  • Start date Start date
S

Steffan A. Cline

When using this as indicated and trying to set it to accept multiple
formats, it bombs out with the error:

Overload resolution failed because no accessible 'TryParse' accepts this
number of arguments

The code looks like this:

ok = Decimal.TryParse(tbIll.Text, _
NumberStyles.AllowCurrencySymbol,
NumberStyles.AllowDecimalPoint, NumberStyles.Currency, temp)

Any ideas? I did in fact place the required: Imports System.Globalization at
the top too.

Thanks

Steffan
 
When using this as indicated and trying to set it to accept multiple
formats, it bombs out with the error:

Overload resolution failed because no accessible 'TryParse' accepts this
number of arguments

The code looks like this:

ok = Decimal.TryParse(tbIll.Text, _
NumberStyles.AllowCurrencySymbol,
NumberStyles.AllowDecimalPoint, NumberStyles.Currency, temp)

Try:

ok = Decimal.TryParse (tbIll.Text, _
NumberStyles.AllowCurrencySymbol Or _
NumberStyles.AllowDecimalPoint Or _
NumberStyles.Currency,
System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat,
temp)
 
Try:

ok = Decimal.TryParse (tbIll.Text, _
NumberStyles.AllowCurrencySymbol Or _
NumberStyles.AllowDecimalPoint Or _
NumberStyles.Currency,
System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat,
temp)

Tom,

Thanks, this worked great. Not sure why the documentation didn't clarify
this any better.

-Steffan
 
Steffan said:
Tom,

Thanks, this worked great. Not sure why the documentation didn't clarify
this any better.

-Steffan

I think that it's clear enough...

From the documentation of decimal.TryParse:

"style:
A bitwise combination of NumberStyles values that indicates the
permitted format of s. A typical value to specify is Number."

There is also an example clearly showing this.
 
I think that it's clear enough...

From the documentation of decimal.TryParse:

"style:
A bitwise combination of NumberStyles values that indicates the
permitted format of s. A typical value to specify is Number."

There is also an example clearly showing this.
Can you post a link to where you saw this? I must have missed the example. I
also searched the web and saw several examples but none of which worked. The
book that our school is teaching from even had examples that didn't work.
Seems to be some inconsistencies.

Thanks

Steffan
 
Steffan said:
Can you post a link to where you saw this? I must have missed the example. I
also searched the web and saw several examples but none of which worked. The
book that our school is teaching from even had examples that didn't work.
Seems to be some inconsistencies.

Thanks

Steffan

MSDN: Decimal.TryParse(String, NumberStyles, IFormatProvider, Decimal)

http://msdn2.microsoft.com/en-gb/library/ew0seb73.aspx
 
Back
Top