Results 1 to 24 of 24

Thread: Organizing Ip Ranges

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Arrow Organizing Ip Ranges

    I'm trying to organize ip ranges into their own type. For example, if i load this text document into a listbox:

    209.170.113.9
    213.161.66.236
    209.170.113.31
    209.170.113.7
    60.254.129.78
    209.170.113.24
    209.170.113.17
    206.16.213.8
    206.16.213.14
    66.77.68.17
    206.16.213.8

    Then I'd like my program to put everything next to its own ip range, like:

    209.170.113.9
    209.170.113.31
    209.170.113.7
    209.170.113.24
    209.170.113.17
    206.16.213.8
    206.16.213.14
    213.161.66.236
    60.254.129.78
    66.77.68.17

    Arranging everything into its own sequence, and leaving the "non-sequenced" ones at the bottom. I'm not sure how to do this, so codes and an exampe would really be appreciated. Thanks for any help.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

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

    Re: Organizing Ip Ranges

    Try setting (at build) the ListBox Sorted = True.

    Will yeild (however, different from your sort):
    • 206.16.213.14
      206.16.213.8
      206.16.213.8
      209.170.113.17
      209.170.113.24
      209.170.113.31
      209.170.113.7
      209.170.113.9
      213.161.66.236
      60.254.129.78
      66.77.68.17
    Last edited by Bruce Fox; Jan 2nd, 2007 at 10:22 PM.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    That sort is fine. But i don't understand wha you're trying to say. Could you write me an example?
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Organizing Ip Ranges

    There's no "writing of code" involved... you just set the sorted property of the listbox at design time in the IDE.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    Oh really. Mind showing me the exact option of this?
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

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

    Re: Organizing Ip Ranges

    Within VB, select the ListBox in question from the dropdown list in the 'Proporties Window'.
    Scroll down til you see 'Sorted', then set that to True.

    This is a property that can't be set at Run Time, hence having to set it a build.

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

    Re: Organizing Ip Ranges

    See attached.
    Attached Images Attached Images  

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    Okay, Done. Now, i need it to remove all instances in an ip range except 1. So if i loaded this into a listbox:

    209.170.113.9
    213.161.66.236
    209.170.113.31
    209.170.113.7
    60.254.129.78
    209.170.113.24
    209.170.113.17
    206.16.213.8
    206.16.213.14
    66.77.68.17
    206.16.213.8

    The Output listbox would look like this:


    213.161.66.236
    60.254.129.78
    209.170.113.17
    206.16.213.8
    66.77.68.17


    With only one instance of each IP range. (can be any instance)
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

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

    Re: Organizing Ip Ranges

    When you loading the File, only add ones that are unique (atleast the seond part) to the Sorted ListBox.
    Now its up to you to have a go. When you get stuck post back

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    That made no sense at all. I'm just taking my sorted list box and deleting all duplicates that are in the same ip range and only keep one, and putting the output in another listbox.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    Only add ones that are unique?

    ^^ thats what my program is supposed to be doing, not me.[QUOTE]
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

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

    Re: Organizing Ip Ranges

    Ok then, iterate the first ListBox, and only transfer unique the ones.....

    (Hint: Compare the one your about to transfer against the previous one loaded in the second ListBox)

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

    Re: Organizing Ip Ranges

    Quote Originally Posted by k0zz
    ^^ thats what my program is supposed to be doing, not me.
    Wow, thats amazing............. arn't YOU the programmer?

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    You don't get it. Forget about sorting. I want to load text into a listbox and delete duplicate ip ranges, and only keep one ip from each range. Period. Add the one ip from each range to a new listbox. Nothing else. I'd like to know how to do this.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    Quote Originally Posted by Bruce Fox
    Wow, thats amazing............. arn't YOU the programmer?

    Fricking bs post. The program is the programmers work, smart one.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

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

    Re: Organizing Ip Ranges

    Yeh, and your the one writting the code to prevent/remove dups...

    Oh, BTW, I would calm down a bit if you want assistance

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    Enough bs posts from you. If you don't want to help, then don't post in the forum.
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

  18. #18
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Organizing Ip Ranges

    Nice attitude, considering its YOU who needs free HELP, and most people won't waste their free TIME to help arses.

    There are rules for determining the client IP ranges based on IP class, so in order to get just on client IP for a network address you need to parse based on that consideration first.

    YOU figure that one out yourself. My last post in your thread. Cheers.

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    448

    Re: Organizing Ip Ranges

    How many bs posters are there? Later little kiddos 8-|
    "Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."

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

    Re: Organizing Ip Ranges

    I'm sorry I wasted your time
    VB Code:
    1. 'Assumes that List one is Loaded and Sorted
    2. Private Sub cmdTransfer_Click()
    3. Dim intCount As Integer
    4. Dim intIdx As Integer
    5.  
    6.     intCount = List1.ListCount - 1
    7.  
    8.     For intIdx = 0 To intCount
    9.         If List2.ListCount <> 0 Then
    10.             If Split(List1.List(intIdx), ".")(1) <> Split(List2.List(List2.ListCount - 1), ".")(1) Then
    11.                 List2.AddItem List1.List(intIdx)
    12.             End If
    13.         Else
    14.             'First Item
    15.             List2.AddItem List1.List(intIdx)
    16.         End If
    17.     Next
    18.  
    19. End Sub

    Yeilds:
    • 206.16.213.14
      209.170.113.17
      213.161.66.236
      60.254.129.78
      66.77.68.17

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

    Re: Organizing Ip Ranges

    Quote Originally Posted by leinad31
    Nice attitude, considering its YOU who needs free HELP, and most people won't waste their free TIME to help arses.

    There are rules for determining the client IP ranges based on IP class, so in order to get just on client IP for a network address you need to parse based on that consideration first.

    YOU figure that one out yourself. My last post in your thread. Cheers.
    Agreed leinad31!

    k0zz - everyone know knows how ungratefull you are

  22. #22
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Thumbs up Re: Organizing Ip Ranges

    Quote Originally Posted by Bruce Fox
    I'm sorry I wasted your time
    VB Code:
    1. 'Assumes that List one is Loaded and Sorted
    2. Private Sub cmdTransfer_Click()
    3. Dim intCount As Integer
    4. Dim intIdx As Integer
    5.  
    6.     intCount = List1.ListCount - 1
    7.  
    8.     For intIdx = 0 To intCount
    9.         If List2.ListCount <> 0 Then
    10.             If Split(List1.List(intIdx), ".")(1) <> Split(List2.List(List2.ListCount - 1), ".")(1) Then
    11.                 List2.AddItem List1.List(intIdx)
    12.             End If
    13.         Else
    14.             'First Item
    15.             List2.AddItem List1.List(intIdx)
    16.         End If
    17.     Next
    18.  
    19. End Sub

    Yeilds:
    • 206.16.213.14
      209.170.113.17
      213.161.66.236
      60.254.129.78
      66.77.68.17
    I wouldn't have bothered after his previous posts, but nice code nonetheless =)

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

    Re: Organizing Ip Ranges

    Quote Originally Posted by Rob123
    I wouldn't have bothered after his previous posts, but nice code nonetheless =)
    Thanks Rob123.
    Last edited by Bruce Fox; Jan 3rd, 2007 at 12:16 AM.

  24. #24
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Organizing Ip Ranges

    Just showing alternative methods for doing the same to keep thread somewhat in topic or something weird.
    VB Code:
    1. Private Sub cmdTransfer_Click()
    2.     Dim lngA As Long, bytTable(255) As Boolean, bytCurrent As Byte
    3.  
    4.     For lngA = 0 To List1.ListCount - 1
    5.         bytCurrent = CByte(Split(List1.List(lngA), ".")(0))
    6.         If Not bytTable(bytCurrent) Then
    7.             bytTable(bytCurrent) = True
    8.             List2.AddItem List1.List(lngA)
    9.         End If
    10.     Next
    11. End Sub
    It is the 115th birthday of J.R.R. Tolkien btw.

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