0

I have a Winforms Application, in which I have a Combo Box, and a text box. Combo box has Currency symbols as follows:

USD
GBP
CAD
AUD
JPY
EUR
ISK
PLZ
TRL

etc ..

The user first selects one currency symbol from the above, and then types in a value in a text box, such as, $32.50, etc ..

I need to validate the string that he types into the text box, based on the currency he selected in the Combo Box. Each currency has its own way of writing money values.

For example, if the user selects USD then all of these typed strings shouble be reported as valid:

223.3
2244.44
$3,754.24

However if the user selects TRL (Turkish Lira), in which symbol is placed after the numeric value (to its right), then these should be valid:

223.3
2244.44
3,754.24 TL

How can I achieve this kind of validation ?

Ahmad
  • 12,886
  • 30
  • 93
  • 146

1 Answers1

0

Since you already know the selected language, the easiest solution would be to not validate the symbol. Place an empty label on each side of the textbox and assign them according to the selected currency's symbol. Now you only have to worry about the decimal part, which is quite easy.

0xFF
  • 808
  • 1
  • 12
  • 33