Results 1 to 8 of 8

Thread: Compare GameIDs in list to add to arraylist VB.NET

  1. #1
    khaos64's Avatar
    Joined
    Mar 2012
    Posts
    5
    Userbars
    0
    Thanks
    1
    Thanked
    0/0
    DL/UL
    12/0
    Mentioned
    2 times
    Time Online
    8m
    Avg. Time Online
    N/A

    Compare GameIDs in list to add to arraylist VB.NET

    Quote Originally Posted by ./m View Post
    I'd suggest grouping each gameid structure into it's own array, then shuffle those arrays, then output. That seems like the simplest way IMO
    @./m
    Thanks for the suggestion - I have been able to get all games into their own individual array, but haven't figured out a way to compare one to the next to see if they match to put them in array list together. I did at one point try and delete the "GameID: " portion so the array started right at the ID number, but still didn't know where to go from there. Any suggestions, Thanks.

  2. #2
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,722
    Userbars
    166
    Thanks
    5,907
    Thanked
    33,078/6,609
    DL/UL
    23/36
    Mentioned
    3,867 times
    Time Online
    563d 5h 38m
    Avg. Time Online
    3h 13m
    Err like you said, but instead of removing "GameID:", why not extract the game ID value and the index of the array (to know where you're at) and then compare that way?
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


  3. #3
    khaos64's Avatar
    Joined
    Mar 2012
    Posts
    5
    Userbars
    0
    Thanks
    1
    Thanked
    0/0
    DL/UL
    12/0
    Mentioned
    2 times
    Time Online
    8m
    Avg. Time Online
    N/A
    Quote Originally Posted by Infamous Joe View Post
    Err like you said, but instead of removing "GameID:", why not extract the game ID value and the index of the array (to know where you're at) and then compare that way?
    Thanks for the reply Joe,

    That was my original idea.

    I was trying something like this to extract the ID's, Worked outside the loop but inside gave me an error and wasn't sure how to fix it/going about it a different way .

    Code:
    Dim arl As New ArrayList
            
    
            For Each Itm As String In ListBox.Items
                arl.Add(Itm)
    
            Next
    
            Dim stg(arl.Count) As String
    
            For i As Integer = 0 To arl.Count - 1
                Dim startTPos As Integer = stg(i).IndexOf("GameID: ") + 8
                Dim endTPos As Integer = stg(i).IndexOf(" S")
                Dim result = stg(i).Substring(startTPos, endTPos - startTPos)
                MessageBox.Show(result)
    
    
            Next
    Fiddled a little more and found something that works at extracting the IDs, now just need to figure out the hard part.
    Code:
     For i As Integer = 0 To arl.Count - 1
                Dim var As String = arl(i)
                Dim arl2() As String
    
                arl2 = var.Split(" ")
                Dim result As String = arl2(1)
                MessageBox.Show(result)
    
    
            Next
    Last edited by khaos64; 03-09-2012 at 03:08 AM. Reason: Able to extract ID

  4. #4

    Joined
    Dec 2011
    Posts
    488
    Thanks
    303
    Thanked
    559/263
    DL/UL
    13/4
    Mentioned
    34 times
    Time Online
    1h 58m
    Avg. Time Online
    N/A
    I'm assuming you have lists somewhat like this:

    +-------+-----+-----+------+------+---+
    |gameID|time1|time2|score1|score2|mod|
    +-------+-----+-----+------+------+---+
    |1 |10
    +-------+-----+-----+------+------+---+
    |1 |13
    +-------+-----+-----+------+------+---+
    |2 |44
    +-------+-----+-----+------+------+---+

    etc...

    Basically what I was suggesting was looping through your list, putting each one with a certain gameID into an array of sorts, then sorting THAT array

    I.E. (php-esque psudocode)

    Code:
    games_array = array()
    foreach(gamelist){
        games_array[gameslist['id']] => gamelist
    }
    You'd end up with an array of multiple list items. Sort this however you see fit. Custom data structures might be useful for it as well, depending on your language

  5. #5
    khaos64's Avatar
    Joined
    Mar 2012
    Posts
    5
    Userbars
    0
    Thanks
    1
    Thanked
    0/0
    DL/UL
    12/0
    Mentioned
    2 times
    Time Online
    8m
    Avg. Time Online
    N/A
    Quote Originally Posted by ./m View Post
    I'm assuming you have lists somewhat like this:

    +-------+-----+-----+------+------+---+
    |gameID|time1|time2|score1|score2|mod|
    +-------+-----+-----+------+------+---+
    |1 |10
    +-------+-----+-----+------+------+---+
    |1 |13
    +-------+-----+-----+------+------+---+
    |2 |44
    +-------+-----+-----+------+------+---+

    etc...

    Basically what I was suggesting was looping through your list, putting each one with a certain gameID into an array of sorts, then sorting THAT array

    I.E. (php-esque psudocode)

    Code:
    games_array = array()
    foreach(gamelist){
        games_array[gameslist['id']] => gamelist
    }
    You'd end up with an array of multiple list items. Sort this however you see fit. Custom data structures might be useful for it as well, depending on your language

    Kinda went over my head with that one a little, I don't see how in VB.NET I could do it that way. Since the gameid's could always be changing from 3-4 characters and I don't know of a way to tell the program to recognize that the numbers after "GameID: " is to take identical IDs and make their own array. Not unless it is done someway as Joe had said by extracting the IDs and index to make an array.

  6. #6

    Joined
    Dec 2011
    Posts
    488
    Thanks
    303
    Thanked
    559/263
    DL/UL
    13/4
    Mentioned
    34 times
    Time Online
    1h 58m
    Avg. Time Online
    N/A
    Not sure if VB.NET has associative arrays or maps, maybe Joe can explain it better

  7. #7
    khaos64's Avatar
    Joined
    Mar 2012
    Posts
    5
    Userbars
    0
    Thanks
    1
    Thanked
    0/0
    DL/UL
    12/0
    Mentioned
    2 times
    Time Online
    8m
    Avg. Time Online
    N/A
    Yea, I don't know.

    But I think I may have found a way to do it, with something called a Bubble Sort, I just cant figure out what kind of IF will allow me to add each matching ID to an array and then start a new array once there isn't a match and start adding the IDs of matching to it until a nonmatching and and etc etc

    Code:
    Dim arl As New ArrayList
            Dim arr As New ArrayList
    
    
    
            For Each Itm As String In ListBox.Items
                arl.Add(Itm)
            Next
    
            For k As Integer = 0 To arl.Count - 1
                Dim var As String = arl(k)
                Dim arl2() As String
                arl2 = var.Split(" ")
                arr.Add(arl2(1))
    
    
            Next
            Dim i, j As Integer
            For i = 0 To arl.Count - 2
                For j = i + 1 To arl.Count - 1
                    ''  If arr(i) = arr(j) Then
                    ''
                    ''If Not arr(i) = arr(j) Then
    
                    ''End If
    
                    '' End If
    
    
                Next j
            Next i
    Do you think this maybe be able to do it or am I wasting my time?

  8. #8
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    If you elaborated on your question and included example before and after data, I could help you.

Tags for this Thread

Posting Permissions

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