Results 1 to 3 of 3

Thread: "For Each" with an array???? HOW?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    Hi..

    Any idé how to use For Each with an array?

    Example code please where I can se how to access the array within the For Each loop to..

    Thanks!!

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Code:
    Private Sub Form_Load()
    Dim sArray(1 To 10) As Integer
    Dim sCurrent As Variant ' control variable for processing for each loop **MUST BE OF DATA TYPE VARIANT
    
     'Fill array with random number between 0 and 300
     For i = 1 To 10
        
         sArray(i) = (Rnd * 300)
        
     Next i
    
     'Display array in Immediate Window
     For Each sCurrent In sArray
        
         Debug.Print sCurrent
        
     Next sCurrent
    
    
    End Sub
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100
    TNX!!!

    Perfect =)

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