Hi,
I'm creating a VB 2005 Express application.
I'm new at programming.
I've Bind controls to a DataSet.
How can I know what is the Decimal separator
In the windows settings we can define "," or "." as the decimal separator.
When I get user input from a textbox and perform calculations, if the user enters "0,5" or "0.5" the result will not be the same. How can I prevent this and guarantee the input of only the decimal separator defined in windows
Other question is how can I show the number in a text box with the decimal places defined by me
For example, how can I show the number "2,00" in a text box (or label) (assuming 2 decimals).
As I wrote, this controls (Text property) are bind to the BondingSource.TableField of a table...
Thanks,
Pedro

Decimal separator/Decimal places
cbeasle1
Hi,
The comma versus dot is determined by the current UI culture of the thread. You can change this culture to match the one you need:
http://msdn2.microsoft.com/en-us/library/system.threading.thread.currentuiculture.aspx
For the validation, you can use Billy Hollis' validation control. Just drop a TextBox validator on your form, select the textbox that must be restricted to a decimal, go it the properties and select the DataType to be DecimalType:
http://dotnetmasters.com/
If you want to do your own parsing of decimal values here's an example:
class ParserClass
{
static System.Globalization.NumberFormatInfo ni = null;
public ParserClass()
{
System.Globalization.CultureInfo ci =
System.Globalization.CultureInfo.InstalledUICulture;
ni = (System.Globalization.NumberFormatInfo)
ci.NumberFormat.Clone();
ni.NumberDecimalSeparator = ".";
}
public void SomeMethod()
{
double someNumber;
string myNumber = "123.4";
try
{
someNumber = double.Parse(myNumber,ni);
}
catch(Exception)
{
}
}
}
To change the formatting of a bound text box, click on the textbox go in the properties find (DataBindings) the open (Advanced).
On the form that opens select the Text property binding and change the format from No Formatting to Numeric and set the number of decimals to 2.
Good luck,
Charles