• Welcome to Valhalla Legends Archive.
 

Problem with Array

Started by vuther.de, June 04, 2006, 01:23 AM

Previous topic - Next topic

vuther.de

I'm having a problem with finding a user in the array and removing it from the array. What I'm doing is adding the person to the array when they leave, doing a /whois, if they're on, it says they left, if not it says they quit Battle.net, and removing them.

on_leave:

    If frmMain.mnuJoinleave.Checked = True Then
        If p_Info(Index).strProduct = "PX2D" Or p_Info(Index).strProduct = "VD2D" Then
            Queue "/whois *" & Username
        Else
            Queue "/whois " & Username
        End If
            ReDim Preserve l_name(0 To UBound(l_name) + 1)
            l_name(UBound(l_name) - 1).name = Username
            boolQuit = True


on_info:

        If boolQuit = True Then
            If Message Like "*is using*" Then
                For i = LBound(l_name) To UBound(l_name)
                AddChat Index, vbGreen, l_name(i).name & " has ", AC_BOLD_ON, "left ", AC_BOLD_OFF, "the channel."
                ReDim Preserve l_name(UBound(l_name) - 1)
                Exit Sub
            Next i
         End If
        End If


on_error:

     If boolQuit = True Then
        If Message Like "*is not logged on*" Then
            For i = 0 To UBound(l_name)
            AddChat Index, vbRed, l_name(i).name & " has ", AC_BOLD_ON, "quit ", AC_BOLD_OFF, "Battle.net (Signed off)"
            Next i
            ReDim Preserve l_name(UBound(l_name) - 1)
            Exit Sub
        End If


Any help is appreciated. :p

rabbit

Why are you doing ReDim Preserve l_name(UBound(l_name) - 1) in your loops?
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

FrOzeN

~ FrOzeN

vuther.de

Quote from: rabbit on June 04, 2006, 06:39 AM
Why are you doing ReDim Preserve l_name(UBound(l_name) - 1) in your loops?

So it will remove the last thing added.

Frozen: Yes. I liked it. :p

rabbit

You shouldn't be assuming things.  Check what it is before you remove it.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

warz

#5
Quote from: rabbit on June 04, 2006, 09:44 AM
You shouldn't be assuming things. Check what it is before you remove it.

This is what I was telling him. He will need to locate the name in the array, find the index of that name and then delete that name. Then, he willl  need to move every name after that name up one spot to fill in the gap. Then he can safely redim the array. Because, whois to say that the person to be removed from the array is the person sitting at the very end of the array?

UserLoser

Quote from: rabbit on June 04, 2006, 06:39 AM
Why are you doing ReDim Preserve l_name(UBound(l_name) - 1) in your loops?

What I had said