|
-
Jul 8th, 2005, 03:57 PM
#1
Thread Starter
Frenzied Member
Checking from a list
Alright, I have a listbox, and I dont really know much about them, one of the few I dont know alot about. I know some of the basics, but what Im looking to do is run like a check. I have two listboxes, each with items in them. I want to take the first item in the first listbox, and match it with the first item in the second listbox. Im going to use a small command that puts the two together and checks if its valid. Then, after the first two are checked, I want to take the second item in the second list and match it again with the first one. Can someone give me an example loop on how this would work? Thanks in advanced
-
Jul 8th, 2005, 04:58 PM
#2
Re: Checking from a list
try this
VB Code:
Dim i As Integer, x As Integer
For i = 0 To List1.ListCount - 1
For x = 0 To List2.ListCount - 1
MsgBox List1.List(i) & List2.List(x) 'this line holds the 2 joined items.
Next x
Next i
casey.
-
Jul 8th, 2005, 07:07 PM
#3
Thread Starter
Frenzied Member
Re: Checking from a list
No, its kind of hard to explain. Im just confused how I would make the loop. Alright, here is what I have. I got 2 list boxes, this program is desgined to check if your user and passwords are valid. In one list is the username, in the other is the password. What I want to do once started, is for the first item in the user list, to goto a textbox. Then the first item in the second list go into the second textbox. Once that is done, Im going to run a check, and after its complete, its need to continue. When it continues the 2 textboxes will be set to nothing, then I want the first item in the first list to appear again in the first box, and the second item in the second list to appear in the second box. Then it will do the check and continue. I want it to run like this until the second list is empty, or everything checked. I just dont know how the loop would look, thats where I need help.
So the procedure would go like:
1. First item in the first list is put in the first textbox
2. First item in the second list is put in the second textbox
3. The check is run and the two textboxes are cleared
4. The first item in the first list gets put back into the first textbox
5. The second item in the second list is put in the second listbox
6. The check is run and boxes are cleared
7. Process repeats with the first item going back into the first textbox, then the third item on the second list going into the second textbox and running the check again
8. This goes on until the second list is all checked.
Last edited by Inuyasha1782; Jul 8th, 2005 at 07:20 PM.
-
Jul 8th, 2005, 07:28 PM
#4
Re: Checking from a list
Inuyasha1782, I know you are using ListBox's because of the example I made for you a couple days. You need to use just the arrays. The arrays are anything that you Dim at the top of a sub or the form. Let me know if you need an example.
-
Jul 8th, 2005, 07:37 PM
#5
Re: Checking from a list
This looks like you are creating a dictionary cracker, with a list of known user names and different passwords, and would be against the AUP to discuss. Please explain how you would attempt to use this to do anything but that.
-
Jul 8th, 2005, 08:12 PM
#6
Re: Checking from a list
No, I think he has a list of passwords then a list of usernames and wants to check if the username and password are valid. Here is a short example of how I would do it:
VB Code:
Dim strName() As String
Dim strPass() As String
Private Sub Command1_Click()
Dim strMyName As String
Dim strMyPass As String
strMyName = txtName.Text
strMyPass = txtPass.Text
For i = 0 to UBound(strName)
If strName(i) = strMyName then
For j = 0 to UBound(strPass)
If strPass(j) = strMyPass then
' the name and pass are correct
Else
' wrong pass
End If
Next j
Else
' wrong name
End If
Next i
End Sub
-
Jul 8th, 2005, 08:49 PM
#7
Re: Checking from a list
Why would you need that? I'll take care of my own password, thank you.
-
Jul 8th, 2005, 11:10 PM
#8
Thread Starter
Frenzied Member
Re: Checking from a list
rawr! I knew that would come up, I was just hoping I would not get accused of it. On the game, its normal to have many accounts, and this is just a small program to see if they are still valid. Sorry if it was taken in a malicious matter. Anyways, no, Im using listboxes for a reason =0 They need to know what they put dont they... Anyways, I'll check out the coding, thanks.
*Edit* In your coding, what exactly are you doing, you comment that you are checking, when I have my own way of checking, or did I misunderstand you?
-
Jul 8th, 2005, 11:23 PM
#9
Re: Checking from a list
Why would you check one user with all the account passwords? Unless I missed something, that sounds like what you want to do.
-
Jul 8th, 2005, 11:29 PM
#10
Thread Starter
Frenzied Member
Re: Checking from a list
I suck at explaning things rotfl. I messed up in my second post, I ment each password, with each user. Sorry about that, Im still confused about that example though >_<
-
Jul 8th, 2005, 11:37 PM
#11
Re: Checking from a list
If you have a way to validate, this is each user with each corresponding password
VB Code:
Dim i As Integer
For i = 0 To List1.ListCount - 1
MsgBox List1.List(i) & List2.List(x) 'this line holds the 2 joined items.
Next i
-
Jul 9th, 2005, 12:41 AM
#12
Thread Starter
Frenzied Member
Re: Checking from a list
Ok so here is what I have:
VB Code:
Private Sub Command4_Click()
Dim i As Integer
For i = 0 To lstWebsites.ListCount - 1
MsgBox lstWebsites.List(i) & lstPass.List(x) 'this line holds the 2 joined items.
Next i
End Sub
In list one there is Girly, and text. In list two there is Johnny, and cadeo. So when they match it should go Girly, and Johhny. Then text and cadeo. After testing it, it went, Girly Johhny, and Text johnny, but it should of been text cadeo. What happened?
-
Jul 9th, 2005, 12:47 AM
#13
Re: Checking from a list
Sorry about that. I left the x in there. If you used Option Explicit for every form, you would have gotten an error, letting you know that X wasn't declared.
Then you would have seen that I elimated the X loop. Hopefully you would have used the i loop. In your case, i was 0 both times.
VB Code:
Option Explicit
Private Sub Command4_Click()
Dim i As Integer
For i = 0 To lstWebsites.ListCount - 1
MsgBox lstWebsites.List(i) & lstPass.List(i) 'this line holds the 2 joined items.
Next i
End Sub
-
Jul 9th, 2005, 12:55 AM
#14
Thread Starter
Frenzied Member
Re: Checking from a list
Yea I got yours to work. Well from your code above, and this code too, it does it twice. Like it will msgbox two times, I only want it to do it once, so I can check, then do it again, check etc etc. So here is what it looks like:
VB Code:
Private Sub Command4_Click()
Dim i As Integer
For i = 0 To lstPass.ListCount - 1
Pass.Text = lstPass.List(i)
User.Text = lstUser.List(x) 'this line holds the 2 joined items.
Next i
End Sub
See I just want it to enter the first two into the correct box, except it does the second matching ones, basicly as far down as the list can go, since there are only two items. How do you control it to fit what I want?
-
Jul 9th, 2005, 12:59 AM
#15
Re: Checking from a list
You are leaving off some of the code, and I wonder about it, but this is the change that I just made.
VB Code:
Private Sub Command4_Click()
Dim i As Integer
For i = 0 To lstPass.ListCount - 1
Pass.Text = lstPass.List(i)
User.Text = lstUser.List([COLOR=Red]i[/COLOR]) 'this line holds the 2 joined items.
Next i
End Sub
-
Jul 9th, 2005, 01:22 AM
#16
Thread Starter
Frenzied Member
Re: Checking from a list
Yea, thats what I ment, but thats not fixing the problem, it checks the last user and pass. Like the last would be text and cadeo, it skips girly and johnny and goes to text cadeo.
-
Jul 9th, 2005, 01:27 AM
#17
Re: Checking from a list
Oh. I see what you want. You have to declare x as a static
You want to check only one at a time. OK. This will prolly do it.
VB Code:
Private Sub Command4_Click()
static i as integer
if i= lstPass.ListCount - 1 then i=0 ' loop if you repeat
Pass.Text = lstPass.List(i)
User.Text = lstUser.List(i) 'this line holds the 2 joined items.
i=i+1
End Sub
-
Jul 9th, 2005, 01:30 AM
#18
Re: Checking from a list
Sorry Inuyasha, I thought you were looking for a basic password checking this.I misunderstood.
No offense, but please try to read your posts before you submit them and fix grammer/spelling errors. You seem like English might not be your first language, and thats totally fine. It would just help us understand you better if you spent a few extra seconds before you post. Thanks.
-
Jul 9th, 2005, 02:36 AM
#19
Thread Starter
Frenzied Member
Re: Checking from a list
Sorry about that, Ill take that into consideration. Anyways, so that does the first pair, how would you continue it? It's not like Next i or anything, so it's a little bit different for me.
This was kind of my whole problem, just getting the loop right to check all of them.
-
Jul 9th, 2005, 03:46 AM
#20
Re: Checking from a list
I thought you were using a listbox, which is why I have the first statement. If the value is too high, it gets reset to 0. The i=i+1 loops through the listbox. It is using LstPass, which is what I thought you wanted.
VB Code:
if i= lstPass.ListCount - 1 then i=0 ' loop if you repeat
Pass.Text = lstPass.List(i)
User.Text = lstUser.List(i) 'this line holds the 2 joined items.
i=i+1
The static keyword keeps it from resetting i to zero each time.
-
Jul 9th, 2005, 10:26 PM
#21
Thread Starter
Frenzied Member
Re: Checking from a list
Yes, I mean its all right now, it matches up right, but only once. Now that its done it the first time, I want it to continue on, after I do the check. Here is what the code looks like:
VB Code:
Private Sub Command4_Click()
Static i As Integer
If i = lstPass.ListCount - 1 Then i = 0 ' loop if you repeat
Pass.Text = lstPass.List(i)
User.Text = lstUser.List(i) 'this line holds the 2 joined items.
i = i + 1
Check
End Sub
See, the check is just a simple check stament, after it checks the first, I want it to continue on to the second pair.
-
Jul 9th, 2005, 10:32 PM
#22
Re: Checking from a list
That's what I had the first time. To get the next instance, you can just click the button again.
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
|