Problem with numbers in French on a Delphi program

Hello,

I have a program with a combo box that has decimal values from .40 to 1.0.  A user selects this as a selling multiplier for products.  If you select .60 in the combo box, then another edit box displays the selling multiplier at four decimal places, (.6000 in this case.)  

This works great in English.  But if the user changes the Regional Setting to French(Canada) in the Control Panel, I run into problems.  Now, when you select .60 in the box, 60,0000 shows up in the selling mulitplier edit box.  It's as if it's disregarding the decimal in the combo box.

Any ideas on how I can resolve this?

Thanks!
LVL 3
light_bulbAsked:
Who is Participating?
 
JaccoConnect With a Mentor Commented:
Hi there,

This should solve you problem:

const
  USAFormat: TFormatSettings = (
    DecimalSeparator: '.'
  );

procedure TForm1.ComboBox1Change(Sender: TObject);
var
  lnNumber: Double;
begin
  if ComboBox1.ItemIndex = -1 then
    lnNumber := 0
  else
    lnNumber := StrToFloat(ComboBox1.Text, USAFormat);
  Edit1.Text := FloatToStrF(lnNumber, ffFixed, 15, 4);
end;

Regards Jacco
0
 
light_bulbAuthor Commented:
Not sure if that will work or not, I've since found an answer myself.  I had to clear the combo and then repopulate it, replaceing the decimal points with commas.

Thanks though.
0
 
JaccoCommented:
Hi there,

That is the other option. Thanks for the points though.

Regards Jacco
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.