Pictures Change Based On Multiple Checkboxes Follow

0
Avatar
Legacy Poster

I am new to VB Script, and I am trying to figure out how to update picture source based on what checkboxes are checked at print time.  The label can contain between 1 and 4 pictures on it.  However, what those pictures actually are will vary depending on what checkboxes are checked on the data entry form.  There are 10 possible checkboxes.  Essentially I need to check all 10 checkboxes and then take the first 4 (or less) that I find and set the pictures to be whatever is indicated by the checkboxes.  On one label we might use checkboxes 1, 2, and 3, while on the next label we might need 2, 8, 9, and 10.  I don't see any way to accomplish this without VB Script since there is not a 1-to-1 relationship between the pictures and the checkboxes.  I have created named data sources for each checkbox on the data entry label and for each picture on the printed label, but I don't know how to best check everything and assign the pictures.  I can easily use the picture file name as the value for the checkboxes if they are checked, so providing the file names is not a problem.

 

I looked for training videos but didn't find anything to do what I am looking for.  Can anyone point me in the right direction?

 

Thanks!

 

2 comments

0
Avatar
Legacy Poster
Comment actions Permalink

OK, I have had some luck with this process - I have been able to apply some small VB scripting to the named data source for the first picture.  It's currently doing a simple if-then-elseif-elseif-... through all of the checkboxes and stopping on the first one it finds.  My current plan is to repeat the process for the 2nd, 3rd, and 4th pictures except to stop on the 2nd, 3rd, and 4th checked box consecutively.

 

I have 2 questions from this:

1) I tried doing a for loop to cycle through my named data sources for the checkboxes (which were all created back-to-back).  However, the last 4 named data sources that I created - for the pictures - are scattered throughout rather than being either the first 4 or last 4.  In addition, one checkbox shows up twice in the for loop.  Is there a way to make this work?  It would be much better than if-then-elseif-elseif-... balogna.  I suspect that it's just a limitation of how Bartender handles things (my version is 10.1), but I thought I'd ask to be sure.  My code was something like this:

for counter = 1 to 9

    if not IsNull(Format.NamedSubStrings(counter).Value) then
         Value = Format.NamedSubStrings(counter).value
    end if
next

 

 

2) The bigger question - in my checkbox control I have the file name (with path) specified as the value if checked.  However, the value for unchecked is empty.  My "if not IsNull(Format.NamedSubStrings(counter).Value) then" statement tests as true every time, even when unchecked.  Is there a better way to test a checkbox to see if it's checked?  Or do I need to check for the length of the value?  That seems really off to me, surely there's a better way to see if a checkbox is actually checked?

 

 

Thanks for any help you can provide!

0
Avatar
Legacy Poster
Comment actions Permalink

Just a thought on question #2: Did you try IsEmpty() also?

Please sign in to leave a comment.