LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a variant's value as a string

Solved!
Go to solution

Do anyone know how to get a variant value to string and back to variant?

0 Kudos
Message 11 of 13
(2,333 Views)

Well there is no generic way to do the latter. A string looses all information about the initial datatype so if you see "123" this could mean it was a string all along already or it could be an integer, or even a floating point with 0 as fractional part. Or it could have been an enum. Without providing some extra information to the String to Variant data as to the expected type, there is simply no solution.

 

And things get really interesting if you talk about such things as timestamps. Unless you require the string to be in a locale independant format like ISO 8601, you can at best throw your hands in the air in trying to find an automatic method to reliably translate a string back into a timestamp.  7/1/2013 could mean January 7, or July 1, depending in what local (and possibly locale customized format) the string was created. Not to forget that some regions prefer 1.7.2013 and a few other separation characters and order of elements. Deducing the order from the seperator is only a bandaid, but not a secure algorithme.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 12 of 13
(2,328 Views)

He's how I did it.

"If you weren't supposed to push it, it wouldn't be a button."
Download All
Message 13 of 13
(1,552 Views)