|
-
Jun 7th, 2008, 11:37 PM
#1
Thread Starter
New Member
[2008] Multithreading?
Okay, so here it goes. I want to make my code create a thread for each user/password in a designated list. My code is as follows:
Code:
Dim szTmpUser as String, szTmpPass as String
---
Private Function Start() As Boolean
Dim Threadx As Thread
For i = 0 To (ListBox1.Items.Count - 1)
ListBox1.SetSelected(i, True)
ListBox2.SetSelected(i, True)
szTmpUser = ListBox1.SelectedItem
szTmpPass = ListBox2.SelectedItem
Threadx = New Thread(AddressOf LoginUser)
Threadx.Start()
Next i
End Function
---
Private Sub LoginUser()
Dim usr As String, pwd As String
usr = szTmpUser
pwd = szTmpPass
MsgBox(usr & "-" & pwd)
End Sub
However, when I try to use it with 4 accounts loaded into the list, it MsgBox's the same thing four times rather than having each one with different info. Sorry if this explanation isn't clear and thanks for any advice.
-
Jun 8th, 2008, 04:51 AM
#2
Re: [2008] Multithreading?
You need to pass the correct parameters to your thread's function.
You could probably do this by creating a new class with your LoginUser method in it and the username and password properties as well. Declare the object, assign the username and password, and then in your threading call, call that object's Loginuser method.
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
|