|
-
Dec 1st, 2003, 10:12 AM
#1
Thread Starter
Member
Adding Times In List Boxes
I currently have a list box which displays the length of an item. I.e.
2.23
8.12
2.05
6.14
3.11
In a second list box next to it I want to display the start time of each item if they were to be run sequentially. I.e.
2.23 0.00
8.12 2.23
2.05 10.35
6.14 16.49
3.11 20.00
How would I achieve this?
-
Dec 1st, 2003, 10:14 AM
#2
Frenzied Member
how are you calculating the (what I assume to be) the execution time of the different parts? GetTickCount? I would have seperate variables for each part and have one that starts over and one that keeps counting.
-
Dec 1st, 2003, 10:17 AM
#3
Thread Starter
Member
They are just strings added to the list box from a combo box
-
Dec 1st, 2003, 10:18 AM
#4
Frenzied Member
soo... you don't actually calculate them?
If not, you could just add them together as you add them to the first list box and keep adding that time to the other listbox.
-
Dec 1st, 2003, 10:22 AM
#5
Thread Starter
Member
You'll have to forgive me, I'm a new user to VB. Yes your right. However, I will eventually need to move items up and down the list box so the each start time will need to recalculated everytime a move is made. Am I making sense?
-
Dec 1st, 2003, 10:27 AM
#6
Frenzied Member
Yes, you are making sense.
You are going to have to make a routine, that whenever the first listbox is changed, that the second listbox will automatically update with some kind of algorithm. And it will be fairly simple. All you have to do is start at the top with the static "0.00" and then look at the first listbox and add #1 and #2 to get the second listing in the second listbox.
You'll have to simply look at the upper bound of the first listbox and loop through it until you reach the end... add 2 at a time, store that value in the second listbox, then move on with that time and the time of the next length...
I think you understand the logic of what I'm saying... probably just not the coding. You'll want to access the "List" object of the listbox.
-
Dec 1st, 2003, 10:29 AM
#7
Thread Starter
Member
You've hit the nail on the head. What functions should I use?
-
Dec 1st, 2003, 10:36 AM
#8
Frenzied Member
OK, you've got 2 listboxes: lstBox1 and lstBox2 (for example)
You'll want to do something like this:
VB Code:
For i = 0 To lstBox1.ListCount - 1
if i = 0 then
lstBox2.AddItem "0.00"
else
lstBox2.AddItem lstBox2.List(i-1) + lstBox1.List(i)
end if
Next
And you'll want to put that in the lstBox1_Change event.
Or something like that... I didn't test that. You get the idea?
-
Dec 1st, 2003, 10:38 AM
#9
Thread Starter
Member
Thanks for your help, but just one more thing. How do I solve the problem of adding times together (base 60)?
-
Dec 1st, 2003, 10:42 AM
#10
Frenzied Member
umm... what is base 60? Never heard of it.
The only thing I can say is to convert it, add it together, then convert it back!?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|