Results 1 to 2 of 2

Thread: How can remove an item from an array ?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258

    Question

    Hey people how you doing today ? I'm ok thanx for asking .
    Heres what I Got
    Code:
    Public Type User
        Nick As String
        winsockindexnumber As Integer
    
    End Type
    Dim Count as Integer
    Dim usr() As User
    
    
    Public Sub addUser(socknum As Integer, Nick As String)
        Dim Loops As Integer
        Dim this As Integer
        Dim guytoadd As String
        Dim total As Integer
    
        frm_Server.lst_users.Visible = True
        
        ReDim Preserve usr(Count)
        
        usr(Count).winsockindexnumber = socknum
        usr(Count).Nick = Nick
        Count = TheCount + 1
        
        For i = 0 To UBound(usr) 
            frm_Server.lst_users.AddItem usr(i).Nick 
        Next i
        
    End Sub
    That creates my array of users , No problem . What I Need to be able to do is remove a possition from the array , while not losing the array . Lets say I have 3 entries how can I remove one . I figure that the indexs will change but thats not a problem
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  2. #2
    Lively Member quadoc's Avatar
    Join Date
    Jan 1999
    Location
    Ga, USA
    Posts
    83
    Here the code to remove an item from the array and List box:


    for i = 0 to UBound(usr)
    if usr(i).nick = "Target string" then
    idx = i
    for k = i to UBound(usr) - 1
    usr(k)= usr(k+1)
    next k
    end if
    next i
    frm_Server.lst_users.removeitem idx



    VB6(SP4), QB4.5, PDS7.0, IBM-U2

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