Results 1 to 3 of 3

Thread: For Each Loop

  1. #1
    Join Date
    Feb 2005
    Posts
    333

    Unanswered: For Each Loop

    I have a string that is semicolon delimited that contains several directory paths. This is how I am parsing the string
    Code:
        fullPath = Split(colUserEnvVars.Item("path"), ";")
        
        cnt = 0
        For Each i In fullPath
            splitPath = splitPath & objshell.expandEnvironmentStrings(fullPath(cnt)) & vbCrLf
            cnt = cnt + 1
        Next i
    It seems like I should not need to use a incremental counter but if I try to do
    Code:
    splitPath = splitPath & objshell.expandEnvironmentStrings(fullPath(i))
    I get a type mismatch error.

    What's the best way to clean up this loop? What command returns the length of an array?

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Try:
    Code:
    For i = 0 to UBound(fullPath) - 1
       splitPath = splitPath & objshell.expandEnvironmentStrings(fullPath(i)) 
    Next i
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Feb 2005
    Posts
    333
    Thanks Teddy. I just found the ubound function in MSDN.

Posting Permissions

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