LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

incorrect variant to double coversion from Excel with Eurpoean language

I apologise for not having code to post right now - I will do that from work tomorrow. But there is a previous thread that describes the same issue that I just found:

http://forums.ni.com/t5/LabVIEW/Wrong-result-after-convert-variant-to-double/m-p/953419


I have a compiled LabVIEW program that runs just fine on an English-language computer - it loads floating point numbers from either (European-formatted) CSV files or Excel xls(x) spreadsheets, communicating with Excel using ActiveX in both cases.  What I see is exactly what is seen in the above thread - the Variant values are displayed on the Front Panel with the Decimal point, but when you convert the variant array to a double array, the number is interpreted incorrectly and the decimal separator is ignored.

 

In otherwords if the Excel file had a value 4.556 (which is formatted as 4,556 in the European files), a Variant Indicator on the front panel displaying the value would display "Value->4.556E+00", but if you then convert it to a double, it would be interpreted as 4556 (or 4.556E+03) (4 thousand 5 hundred and 56).  The LabVIEW program is using the European locale settings for displaying other floating point values on the front panel.  It seems that LabVIEW is forgetting to use the Locale settings in the Variant->Double conversion (or some other inconsistency).  Why does it display it ok in the Variant Indicator, but then get mis-interpreted?

0 Kudos
Message 1 of 9
(4,202 Views)

What?

 

So sorry, my screen isn't large enough to read your post. 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 9
(4,193 Views)

Maybe the OP has eye trouble and needs to have BIG font in order to read.  I knew a guy with retinal damage, and he had to use big fonts.  He had no choice.  Even glasses would not help much.

@pauldavey.  Sorry I don't know the answer to your question.

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 9
(4,169 Views)

I am digging it on my iPhone...

0 Kudos
Message 4 of 9
(4,162 Views)

ROFL!!  Guys...

😄

 

Simply mention that smaller fonts should be used and let's help this person..

 

Sorry.. I just had to laugh, it was funny, and I think everyone needs laughter these days..

 

🙂

0 Kudos
Message 5 of 9
(4,135 Views)

 

Sorry - I had trouble with a conflict between font size and web browser magnification (I pressed Ctrl Y and it all went downhill from there).  If I could still edit the post I would.  I have had trouble trying to reproduce it since I have a Windows machine using English.

Message 6 of 9
(4,117 Views)

How do you convert it back? Ordinary Variant to Data? If you unflatten you'll get the decimal comma and later transforms will get messed up.

I've had some problems with outsmarting LV due to such inconsistencies which later on outsmarted me.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 9
(4,109 Views)

Hi   Yamaeda

 

Thanks for your reply.  I am simply using the Variant To Data function to convert the Variant (from the Value2 property of the range) to a 2D DBL array.  I have tried changing the language on my computer to German with German local settings, and everything looks German, with commas for decimal and dots for thousands (and swapping the Z and Y keys on my keyboard!).  But on my computer everything works flawlessly.  We are going to try changing the German computer to use English and see if that works.

 

Paul

0 Kudos
Message 8 of 9
(4,099 Views)

If the only difference is the comma/point and not thousand separators (1,000.00 vs 1'000,00) then you could try the following:

Use Unflatten variant -> (String part) Replace string 'comma to point' -> String to number with "Use regional setting" set to false.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 9
(4,091 Views)