LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Padding String with 0's on the left - A better, Simple method?????

smercurio and Altenbach, thanks for the feedback.  I spent another evening looking at the code to determine how best to procede...any input would be appreciated and it'll contribute to my ongoing learning 🙂  For your viewing pleasure, I'm attaching two VIs.  There is a subVi, which rearranges the elements of the original array and deletes some columns and 1 row.  Then the "main" VI will print this array to a label printer, to be attached to sample vessels. I understood that the numbers were already strings and so the decimal formatting was hopeless...just got off on a tangent chasing butterflies and lost sight of reality...problem is, these values are ALWAYS strings; they are never numbers.
Download All
0 Kudos
Message 11 of 19
(2,052 Views)
Here is the Vi that creates the array to begin with...thought this would help...
0 Kudos
Message 12 of 19
(2,050 Views)
seems like the crux of the problem is how and where I can effectively truncate the numbers to 3 decimal places.  I've tried it so many different places.  It displays correctly on the ActiveX Excel on the front panel, but somewhere downstream the formatting is lost and it displays way too many digits.  I always use the values 1 and 3 in the spreadsheet, since the division functionw will result in a repeating decimal 3...
0 Kudos
Message 13 of 19
(2,049 Views)
So here is what I DO NOT get...as teh two screen captures show, the front panel Spreadsheet (ActiveX container) shows the values formatted correctly (3.333 is 3 decimal places). That Spreadsheet reference is brought in and I grab the range of its cells and write them to a file (append) and print them to a label.  I can't see where the formatting is reverting back to 14(+) decimal places....Whether I try to format the number as I do in the Print portion, or leave it alone as I do in the append to file portion, it seems to have no effect on the formatting
0 Kudos
Message 14 of 19
(2,036 Views)

You need to differentiate between the internal representation of the data and how your activeX container is formatting it for display. These are two different things.

0 Kudos
Message 15 of 19
(2,028 Views)
OK, that makes sense.  The object I see on the front panel is not the spreadsheet itself, but just an "amage" of it that allows me to interact with it.  So I have a template (which includes formulas) that I use to create this image, then I interact with the image by adding values, which are then acted upon my forulas to populate other cells of the image.  Then this image is used to append data to a spreadsheet file and to print labels.  The problem is that I can't understand where to get to the data to format it, since it doesn't seem to truly exist anywhere except in memory.  I've gone in long ago and formatted the appropriate columns in the excel template that I call...seems to have no bearing...
0 Kudos
Message 16 of 19
(2,023 Views)

There were some subVIs missing, so I can't tell what's going on under the hood. There also seem to be some linking problems - the top-level VI that you uploaded is looking for "Print Label", but you uploaded "Print Label 1". 

 

Side-notes:

  • In your top-level VI none of your local variables are necessary at all. Use wires and connect to the terminals. That's what they're there for.
  • The spreadsheet control that you're using is NOT Excel. A lot of people make this assumption because it looks like an Excel spreadsheet. While it shares similarities, it's a different control from Microsoft with a different object model. 
Message Edited by smercurio_fc on 07-20-2009 10:29 AM
0 Kudos
Message 17 of 19
(2,013 Views)
Continued here....
0 Kudos
Message 18 of 19
(1,983 Views)

Maybe an old post, but real life saver.  I was the same and missed such an elegant solution

0 Kudos
Message 19 of 19
(1,378 Views)