How to remove an element from an array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesnkk
    New Member
    • Nov 2006
    • 134

    How to remove an element from an array

    Hi, I have created an array using Lbound like below -


    Function StoreForm(strte xt)

    If blDimensioned = True Then
    ReDim Preserve strFrmNames(0 To UBound(strFrmNa mes) + 1) As String
    Else

    ReDim strFrmNames(0 To 0) As String
    blDimensioned = True
    End If
    strFrmNames(UBo und(strFrmNames )) = strtext
    ------------------------------------------------------------------------------------------------------
    I can go thru the element one by one of an array and fire out the form

    For lngPosition = LBound(strFrmNa mes) To UBound(strFrmNa mes)
    frmName = strFrmNames(lng Position)
    Call Displayform(frm Name)

    Next lngPosition
    End If

    The Question is after I process each of the item, how should I delete the item from an array ? and do I have to redim ?

    Please assist
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by jamesnkk
    The Question is after I process each of the item, how should I delete the item from an array ? and do I have to redim ?

    Please assist
    Yes, if you want to remove the nth element, then you should move one place form the (n+1)th element to the last one.

    and yes, you should redim.

    Anyway, i'll keep subscribed in case someone knows a better solution.

    Comment

    • jamesnkk
      New Member
      • Nov 2006
      • 134

      #3
      Originally posted by kadghar
      Yes, if you want to remove the nth element, then you should move one place form the (n+1)th element to the last one.

      and yes, you should redim.

      Anyway, i'll keep subscribed in case someone knows a better solution.
      Thanks you so much, I take note on that

      Comment

      Working...