Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Decimal.TryParse not working right

Status
Not open for further replies.
Joined
Aug 1, 2003
Messages
39
Location
US
By looking at the following code can anyone tell me why 5 typed into txtNorthCurrent.txt returns true and 5.0 returns false?

Dim isconverted As Boolean
Dim currentSalesNorth As Decimal
isconverted = Decimal.TryParse(txtNorthCurrent.Text, NumberStyles.AllowCurrencySymbol Or _
NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo, currentSalesNorth)

Thanks in advance

--------------------------
Thanks
Brian

 
Ok Never mind

I changed it to say

Dim isconverted As Boolean
Dim currentSalesNorth As Decimal
isconverted = Decimal.TryParse(txtNorthCurrent.Text, NumberStyles.Currency, NumberFormatInfo.CurrentInfo, currentSalesNorth)

I put NumberStyles.Currency and took out the other two number styles and it now works ok and keeps the decimal and does not return a zero.

--------------------------
Thanks
Brian

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top