I am reading some pdf files and need to determine the origin af a value. Like in Norway we write 1 050,00, in UK 1.050,00. And as I remember som countries write 1,050,00.
I use Double.Parse(str_Value,System.Globalization.CultureInfo.CreateSpecificCulture(“No-no”)).ToString(“F2”) to convert if string is Norwegian and Double.Parse(str_Value,System.Globalization.CultureInfo.CreateSpecificCulture(“En-en”)).ToString(“F2”) if UK.
But is there a way to read string to determine if it is Norwegian or UK?
CultureInfo.CurrentCulture.DisplayName does just give me an integer, so does CultureInfo.CurrentCulture.ThreeLetterISOLanguageName.
How to display real name like “nor” so I can use the correct double parse? Hope you understand my question
If I remember correclty, the CurrentCulture is set to InvariantCulture by default. You can set a value to it in the beginning of your automation, but since your problem is related to determining the culture based on a number string, I guess it won’t help.
How about using TryParse instead of Parse, and checking in an If-Else whether the parsing was succesful or not?
If your idea is to use a single parse statement then cultureinfo.InvariantCulture ahpuld suffice your requirement as it automatically chooses the cultureinfo that best suites the given number
If your requirement is to identify the culture info only from number, then I am afraid if you can determine…
I am using regex to determine pattern of value and then parse to double. Had hoped that it was possible directly when reading value to then select correct culture info to parse. As I do now I read all values, check with regex and then replace value in text to get all in same culture. Makes it a little easier to use values later in flow.
Use this to find highest value in array:
str_Highest_amount = ((MatchBeløp_in_string.Cast(Of Match).Select(function (x) x.Groups(0).toString.Trim).ToArray()).Max(function(x) cdbl(x))).ToString(“#.00”).Trim