Convert from a String to a Numeric Data Type in LabVIEW

Updated Sep 15, 2018

Reported In

Software

  • LabVIEW

Issue Details

  • I need to convert a string to a numeric data type, but it is cutting off the numbers following the decimal place. How do I convert to a floating point numeric representation from a string?
  • I have a string that represents numbers with a comma for the decimal point instead of a period. I need to convert my string data with a comma for the decimal point to numeric data. How do I do this?

Solution

LabVIEW 6.0 and later
  1. Use the Fract/Exp String to Number function (Functions Palette » String » String/Number Conversion
  2. Set the input called use system decimal point to TRUE to use the localized decimal separator, which will be a comma if that is what you have in your string
 
This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project.  To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW block diagram
 
LabVIEW 5.0 and earlier
  1. Use the Scan from String function (Functions Palette » String).
  2. Specify a format string that tells the function what to look for in the input string. To edit the format string right click on the Scan from String icon and choose Edit Scan String. The pattern for specifying the decimal separator is the percent sign followed by the decimal separator you choose followed by a semi-colon. Which is %,;%f for the comma case.

This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project.  To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW block diagram

WAS THIS ARTICLE HELPFUL?

Not Helpful