Groups | Blog | Home
all groups > vb.net > february 2007 >

vb.net : Double.TryParse


Steffan A. Cline
2/10/2007 9:06:30 PM
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
Tom Shelton
2/10/2007 9:44:59 PM
[quoted text, click to view]

Try:

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

--
Tom Shelton
Steffan A. Cline
2/11/2007 2:11:30 AM
in article 1171172699.667711.142740@v45g2000cwv.googlegroups.com, Tom
Shelton at tom_shelton@comcast.net wrote on 2/10/07 10:44 PM:

[quoted text, click to view]

Tom,

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

-Steffan
Steffan A. Cline
2/12/2007 5:05:02 PM
in article ejEAPRuTHHA.4276@TK2MSFTNGP02.phx.gbl, Göran Andersson at
guffa@guffa.com wrote on 2/12/07 1:27 PM:

[quoted text, click to view]
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
Göran_Andersson
2/12/2007 9:27:51 PM
[quoted text, click to view]

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.

--
Göran Andersson
_____
Göran_Andersson
2/15/2007 2:36:41 AM
[quoted text, click to view]

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

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

--
Göran Andersson
_____
AddThis Social Bookmark Button