Hi there! I am working on a sort of lottery type prog to demonstrate to students what probability is. Ofcourse it is all in good fun, but I was wondering, if I have a listbox called numList, and a label called numaddLBL, is there a way to add the label ItemLBL.caption to the numList depending on the number of the numAddLBL.caption?
For example is there a better way of doing this?
if numaddLBL.caption = "1" then
numList.add item ItemLBL.caption
end if
if numaddLBL.caption = "2" then
numList.add item ItemLBL.caption
numList.add item ItemLBL.caption
end if
if numaddLBL.caption = "3" then
numList.add item ItemLBL.caption
numList.add item ItemLBL.caption
numList.add item ItemLBL.caption
end if
Cause if the student entered 50, for example, that is 50 lines of redundant code... :) If there a better way to set it up, so the program will just add the item from the itemLBL.caption just as many times the numaddLBL.caption says to. :) thanks!
For example is there a better way of doing this?
if numaddLBL.caption = "1" then
numList.add item ItemLBL.caption
end if
if numaddLBL.caption = "2" then
numList.add item ItemLBL.caption
numList.add item ItemLBL.caption
end if
if numaddLBL.caption = "3" then
numList.add item ItemLBL.caption
numList.add item ItemLBL.caption
numList.add item ItemLBL.caption
end if
Cause if the student entered 50, for example, that is 50 lines of redundant code... :) If there a better way to set it up, so the program will just add the item from the itemLBL.caption just as many times the numaddLBL.caption says to. :) thanks!