PDA

View Full Version : Listbox running totals



RodB
12-19-2005, 01:06 AM
Hello

I have 12 listboxes with numbers as selections , and 1 Label object , how do I do this , as a user selects a number in one listbox than selects another number in another listbox and another so on and so on , that the Label object keeps a tally by adding the choesn numbers together and displaying the running total number .

Thanks Rod

RodB
12-19-2005, 02:35 AM
Sorry Guys they are 12 combo boxes .

Rod

RodB
12-19-2005, 03:47 AM
Ive hacked me way this far but hit a bit of a wall , my combo boxes have 3 slots with the numbers 8 9 10 , but this dont display the number selected but the slot number its sits in the combo 1 2 or 3 is displayed .

I also tried to set BR1 as a variable so I can add it to the next combo selection , I dont know it thats the right way to do what I want , heres the code that displays the wrong numbers .


Thanks Rod

selected_item = ComboBox.GetSelected ("B1");
if (selected_item ~= nil ) then

Label.SetText("BScore", selected_item)
BR1 = selected_item

end

Stefan_M
12-19-2005, 05:27 AM
litle project with 6 comboboxes

see:
1. Project / Global Functions / function 'math()'
2. ComboBox Properties / Script / On select


Stefan_M

RodB
12-19-2005, 06:09 AM
Good one Stefan I,ll hook into it and see what I can see :)

Thanks Rod

RodB
12-19-2005, 06:34 AM
I just had a look at and cant get the gist of it , the combo boxes work the same mine do , where you select say No 12 in the 3rd row and it displays 3 in the input box I want it to display the 12 .

I,ll keep diging at it , the answer is prolly in it but Im having a hard time seeing it .

Rod

Stefan_M
12-19-2005, 06:56 AM
its the function: ComboBox.GetItemText



_selected = ComboBox.GetSelected("ComboBox"..x);
sum=sum+ComboBox.GetItemText("ComboBox"..x,_selected)


Stefan_M

RodB
12-19-2005, 03:53 PM
Stefan , does this , get the item as a text or a number , I need it to be a number so that I can set it as as a varible , so that if no 12 is selected thats whats displayed and a varible is set for 12 , does that make sense ;)

Thanks Rod

Worm
12-19-2005, 03:58 PM
_selected = ComboBox.GetSelected("ComboBox"..x);
sum=sum+String.ToNumber(ComboBox.GetItemText("ComboBox"..x,_selected))

RodB
12-19-2005, 04:47 PM
Ah , thanks Worm .

Rod

bule
12-21-2005, 08:16 AM
You might rather use datagrid plugin instead a 12 listboxes for that...