Results 1 to 12 of 12

Thread: Looping through listboxes[Resolved]

  1. #1

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Resolved Looping through listboxes[Resolved]

    Basicly I am taking one item from one listbox and matching it with all the other items in the second listbox. Here is what it looks like:

    VB Code:
    1. Dim Check As Boolean
    2. For X = 0 To List1.ListCount - 1
    3. Check = PortCheck(List2.List(0), List1.List(X))
    4. If Check = False Then
    5. Status.Caption = "Moving on..."
    6. End If
    7. Next X

    Now, that will go through the portcheck with each item in the second listbox. Now here is what I am having trouble figuring out how to do. Once the second listbox has ran out of items to check with, I want the first item in the first listbox to move down one, then repeat the same loop as shown above. So basicly I just need to put the above loop in a bigger loop, but I really can't figure out how >_< Any help would be nice
    Last edited by Inuyasha1782; Aug 10th, 2005 at 11:14 PM.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Looping through listboxes

    VB Code:
    1. Dim Check As Boolean
    2. For X = 0 To List1.ListCount - 1
    3. For i = 0 to list2.listcount - 1
    4. Check = PortCheck(List2.List(i), List1.List(X))
    5. If Check = False Then
    6. Status.Caption = "Moving on..."
    7. End If
    8. Next i
    9. Next X

    I think thats right

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Looping through listboxes

    Put a 'nested, For Next structure using the ListCount of the 'other' ListBox.

    VB Code:
    1. For x = 0 to List1.ListCount -1
    2.     For y = 0 to List2.ListCount -1
    3.  
    4.         'Bla
    5.  
    6.     next y
    7.  
    8. next x

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Looping through listboxes

    What are you comparing? You want to find item A in list B for each item in A?
    The, if you find it, what do you want to do?

  5. #5

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Looping through listboxes

    I'll try those other to thanks.

    dglienna, I am comparing an Ip with ports, when the Ip and port match, I log it, basicly just a simple port scanner except for multiple Ip's. So yes, I take one Ip scan it with each port, and now when im done with that, I want to move onto the next Ip, I think that's what you said.

    *Edit* Erm, I dont think those other 2 are quite what I wanted. Don't those just match each item in each listbox with each other?
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  6. #6

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Looping through listboxes

    Okay, that's doing it backwards ^^ I want it the other way around, that's just doing one Ip with one port, then the second Ip with the same first port. I want it the First Ip with the first port, then the first Ip with the second port, etc etc.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  7. #7
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Looping through listboxes

    Maybe?
    VB Code:
    1. Dim Check As Boolean
    2. For i = 0 to list2.listcount - 1
    3. For X = 0 To List1.ListCount - 1
    4. Check = PortCheck(List2.List(i), List1.List(X))
    5. If Check = False Then
    6. Status.Caption = "Moving on..."
    7. End If
    8. Next X
    9. Next i

  8. #8

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Looping through listboxes

    Alright that works One last thing, how would I show the selected Port and Ip it's on? Like the current one it's one, I want to be selected in the list.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  9. #9
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Looping through listboxes

    VB Code:
    1. Dim Check As Boolean
    2. For i = 0 to list2.listcount - 1
    3. For X = 0 To List1.ListCount - 1
    4. msgbox list2.list(i) & list1.list(x)
    5. Check = PortCheck(List2.List(i), List1.List(X))
    6. If Check = False Then
    7. Status.Caption = "Moving on..."
    8. End If
    9. Next X
    10. Next i

    BTW, you should learn how to format your code for easier reading

  10. #10

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Looping through listboxes

    I know, I have been working on it, I usually only tend to really do it when I submit all my code, but im working on it ^^

    Also, I ment you know how you can highlight things in a listbox. I want the current Ip and Pass it's on to be highlighted in the listbox.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  11. #11
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Looping through listboxes

    VB Code:
    1. Dim Check As Boolean
    2. For i = 0 to list2.listcount - 1
    3. List1.Selected(i) = True
    4. For X = 0 To List1.ListCount - 1
    5. List2.Selected(x) = True
    6. Check = PortCheck(List2.List(i), List1.List(X))
    7. If Check = False Then
    8. Status.Caption = "Moving on..."
    9. End If
    10. Next X
    11. Next i

    That should do it

  12. #12

    Thread Starter
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 2005
    Location
    California, USA
    Posts
    1,035

    Re: Looping through listboxes

    Thanks for all the help *I would rate, but you help me to much *
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width