LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Leading zeros in numeric control

Solved!
Go to solution

Hi 

I am pretty new to labview and learning.  I am trying to enter a number 003330 in a numeric control in my vi  But it drops all the leading zeros.  I cannot define this as a string as I will be passing this value from the output of the previous step in the teststand sequence which is Type: Number (dbl).  Thanks for the suggestions.  

0 Kudos
Message 1 of 21
(6,058 Views)

The value of the number is going to be 3330 regardless of what formatting you have selected on your numeric control. There is no way to make the value remember the formatting of the control. 

 

What kind of data is it? Why do you need the leading zeroes? Is the total length always the same, like a serial number? 

0 Kudos
Message 2 of 21
(6,056 Views)

Hi Greg

 

Thanks for immediate reply.  This is a the data read from the scanner and it is a serial number with a fixed width.  The data has been stored as a type: number in the stationglobals in the teststand which uses around 97 steps.  I need this leading zeros as I am calling this number as the input to my vi to match the first digit with another number to identify the product and to validate the testing.  The serial number will have different first digits starting from 0 - 3.  Depending on the first digit it would be identified with different product.  If you need any more information please let me now. Thanks.

0 Kudos
Message 3 of 21
(6,051 Views)

Hmm... it definitely sounds like string or integer would be a better choice for the datatype, is someone tell you that you can't change it?

0 Kudos
Message 4 of 21
(6,041 Views)

Yes, its been a number for a long time and its been used in the same data format in several other vi's in other steps.  I am trying to find a way to read this number in my vi without disturbing other vi's and the whole test sequence. 

0 Kudos
Message 5 of 21
(6,037 Views)
Solution
Accepted by topic author vvk07

You can format the double as an integer string. The "06" tells it to pad with zeroes to get the minimum width of 6 digits. This seems far from ideal because I assume different products could have different length serial numbers.

 

Capture.PNG

Message 6 of 21
(6,036 Views)

Yes you are right.  Different product have different length serial numbers. The existing products have a length of 6.  

0 Kudos
Message 7 of 21
(6,026 Views)

Right click on your control, choose display format. Check the box for minimum field width and change it to pad with 0

0 Kudos
Message 8 of 21
(6,025 Views)

I tried that, it added leading zeros in the numeric control display, but drops it in the block diagram when I want to use it for further comparisons.

0 Kudos
Message 9 of 21
(6,017 Views)

The solution I provided will give you a string with the desired amount of padding on it.

0 Kudos
Message 10 of 21
(6,013 Views)