|
-
Jul 18th, 2005, 10:40 AM
#1
Thread Starter
Junior Member
Looping through 2 list boxes
kinda a continuation to my other thread, but i think it would just be better to start a new thread..
Ok, i have 2 list boxes (list1, list 2), a web browser, and a start button.. I have it so the emails are in one list box, list1, and the passwords are in the 2nd listbox, list2. I highlight the first login in each box, and it sucessfully works, but i havent set it to go down the whole list of emails and passwords to do the same thing to each one to the end of each list box, i dont know how to do that.. i suppose it would be some kind of do/loop but i cant figure it out... There is also a load button, to load the txt file into the list boxes, but thats not really important because that already works.
-
Jul 18th, 2005, 10:54 AM
#2
Re: Looping through 2 list boxes
VB Code:
Dim i As Long
For i = 0 To List1.ListCount - 1
'do whatcha gotta do through each loop here.
Next
-
Jul 18th, 2005, 11:01 AM
#3
Re: Looping through 2 list boxes
VB Code:
For i = 0 To List1.ListCount - 1
'do whatcha gotta do through each loop here.
Next [b]i[/b]
-
Jul 18th, 2005, 11:03 AM
#4
Fanatic Member
Re: Looping through 2 list boxes
VB is a mixture of sequential and event driven.
Actions etc can fire off events in VB code.
However code that is being executed also has a desire to continue to the next line.
(Until it reaches the exit point of it's procedure.)
The answer probably depends on what needs to happen between lines ?
You could set up a loop such as -
VB Code:
For i = 0 To lbo1.ListCount - 1
'code doing stuff for each line
' using lbo1(i).List(i)
Next i
That loop will process each line in sequence, until it runs out of data.
However you may not want the 2nd line jumping in too soon ?
So we may need to know a bit more about your 'needs'
-
Jul 18th, 2005, 11:03 AM
#5
Re: Looping through 2 list boxes
 Originally Posted by |2eM!x
VB Code:
For i = 0 To List1.ListCount - 1
'do whatcha gotta do through each loop here.
Next [b]i[/b]
What is the difference between your post and mine?
-
Jul 18th, 2005, 11:37 AM
#6
Thread Starter
Junior Member
Re: Looping through 2 list boxes
do i need to have 2 for/next loops though? cause i have 2 list boxes that need to change at the same time, you know?
-
Jul 18th, 2005, 11:41 AM
#7
Re: Looping through 2 list boxes
 Originally Posted by Josh2022
do i need to have 2 for/next loops though? cause i have 2 list boxes that need to change at the same time, you know?
Yes, you would and they should probably both be in the same code routine.
-
Jul 18th, 2005, 11:45 AM
#8
Re: Looping through 2 list boxes
If you have to do something to each item in both listboxes at the same time, then there's no reason for the second loop. The first one tells you the item number of both listboxes.
-
Jul 18th, 2005, 11:52 AM
#9
Re: Looping through 2 list boxes
 Originally Posted by Josh2022
...to do the same thing to each one to the end of each list box, i dont know how to do that.. i
If you only need to do one thing to one of the listboxes, then dglienna is right, but based on the above comment, I thought you needed to do something to each listbox each time.
-
Jul 18th, 2005, 11:54 AM
#10
Re: Looping through 2 list boxes
@ hack, i thought that every for loop had to have a corresponding next..
anyway i guess its good coding to use it
-
Jul 18th, 2005, 12:42 PM
#11
Thread Starter
Junior Member
Re: Looping through 2 list boxes
wow, you guys are so helpful! thankyou. ^_^
-
Jul 18th, 2005, 12:45 PM
#12
Re: Looping through 2 list boxes
 Originally Posted by |2eM!x
@ hack, i thought that every for loop had to have a corresponding next..
anyway i guess its good coding to use it
You do have to do a cooresponding Next, but you don't have list the looping variable. VB is smart enought to figure out what Next goes with what For, and if your code is properly indented, as it should always be, it is easy enough for anyone to figure out what does with what.
 Originally Posted by josh2022
wow, you guys are so helpful! thankyou
So, how are you doing on coding this issue? Are you still running into some difficulties.
-
Jul 18th, 2005, 12:51 PM
#13
Re: Looping through 2 list boxes
If it's usenames and passwords, there is a one to one correlation, so that's why I posted what I did.
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
|