Reputation: 885
I'm trying to do a tryparse on a single with the proper culture setted and allowing the currency symbol but nothing seems to work
This is the condition
If (Not Single.TryParse(e.FormattedValue.ToString, NumberStyles.AllowCurrencySymbol, CultureInfo.CurrentCulture, dTemp) OrElse dTemp < 0) Then
MsgBox("La valeur ne doit pas être négative ni être une lettre. Ne laisser pas la case vide non plus.")
e.Cancel = True
End If
With a value like 98,00 $
it go into the condition....
So how do I make it understand that the Currency is not to be taken care of, without some complciated string builder, basicly what am I doing wrong
Upvotes: 0
Views: 220
Reputation: 216313
Try to change the parameter for NumberStyles to NumberStyles.Currency
If (Not Single.TryParse(e.FormattedValue.ToString, NumberStyles.Currency, _
CultureInfo.CurrentCulture, dTemp) OrElse dTemp < 0) Then
.....
However if you expect your string to be a currency value, probably I would use a decimal instead of a single
Upvotes: 1