Results 1 to 4 of 4

Thread: For Next Statement - Until end or array?? {Solved}

Hybrid View

  1. #1

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Resolved For Next Statement - Until end or array?? {Solved}

    Hi, im guessing this answer is very simple so sorry for the easy question, I just for some reason couldn't find the answer.

    All I want to do is go through an array until you hit the last index, if that makes any sense. I have an array which could have any amount of indexes..

    So I want to do something like this:
    VB Code:
    1. Private Sub CheckStatus()
    2. Dim Checks() As Integer
    3. Dim CellText As String
    4.  
    5.     CellText = DetailsGrid.CellText((llRow - 2), 5)
    6.     Checks() = Split(CellText, "; ")
    7.    
    8.     For Checks() = 1 To Last
    9.         ' Do whatever..
    10.     Next
    11.    
    12. End Sub
    So what could I do to find out the last index of an array? Im sure you could use LBound and UBound to do it but I have never used them before. Thanx all for the help!
    Last edited by epod69; May 26th, 2005 at 03:22 PM.

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: For Next Statement - Until end or array??

    this should do it



    dim ArrayLength as integer

    arraylength = ubound(checks())

    for i = 1 to arraylength

    or

    for i = 1 to arraylength - 1

    I dont really remember which :/

  3. #3
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: For Next Statement - Until end or array??

    The best way would be:


    For I = LBound(strArray()) To UBound(strArray())

    Next I

    because that will work wether the array is zero based, or anything else.

  4. #4

    Thread Starter
    Addicted Member epod69's Avatar
    Join Date
    Feb 2005
    Location
    Cambridge, WI - USA
    Posts
    239

    Re: For Next Statement - Until end or array??

    Thanx, that did it ^-^!

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