BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi Chris and everybody,

I created a Custom Task for EG4.1 that must be bilingual, that is:
1. must work in English if the user set Tools/Options/General/English(United States)
2. must work in French if the user set Tools/Options/General/French(France)

In my task I need to validate user input numbers, entered as strings in textboxes for example “4.25”.
In my VB.NET code, I use the Convert.ToDouble(Me.TextBox1.Text) statement to convert the user’s entry in order to check the value (in the example, Me.TextBox1.Text = “4.25”).

As far as the EG4.1 language settings is Tools/Options/General/English(United States), the string “4.25” is converted to the double 4.25, which is great.

However, when the language settings is Tools/Options/General/French(France), “4.25” CAN NOT be converted to a double, as an exception is raised: “Input string was not in a correct format”. At the same time, “4,25” IS converted to a double, written 4,25 (which I don’t like because I write numerics is my SAS code using a period. And even if I replace the comma by the period when writing to my SAS code, I will have to do the reverse when I populate the form with the task state saved in XMLState. This is laborious!).

So in my CUSTOM TASKS, English(United States) seems to use the period as decimal separator, while French(France) uses the comma.

BUT in NATIVE EG4.1 tasks (those supplied by SAS), the period is used as decimal separator, regardless of the languages settings (English(United States) or French(France)).

So my question is: How do I force my Custom Task to have the same behaviour as the native task? (that is to recognise only the period as the decimal separator regardless of the EG4.1 languages settings).

Thanks for any help!

Maurice2
2 REPLIES 2
Bill_SAS
SAS Employee
You will need to add a second item to the Convert.ToDouble() statement. After your Me.TextBox1.Text add a second argument of "System.Globalization.CultureInfo.InvariantCulture". This will force the Convert.ToDouble() to use the default/US-english locale for the conversion no matter what Tools/Options/General/Locale settings.
ChrisHemedinger
Community Manager
Maurice,

You need to convert your numbers to strings using the InvariantCulture format provider. For example:

double myDouble = 4.25;
string value = myDouble.ToString(System.Globalization.CultureInfo.InvariantCulture);

That will prevent the French culture settings from influencing the text value.

Chris
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1112 views
  • 0 likes
  • 3 in conversation