Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing results from each pass of a For Next loop ?

Status
Not open for further replies.

act2

Technical User
Dec 17, 2005
34
US
This may be a dumb question but here it goes. Is there a way to store the result of each pass of a For Next loop. I want to see the value from each pass stored in a varuble that I can call later.
 
Make use of an array, Here is the sample code in its simple form, you can modify the same code to suit your need.

Code:
Public Function StoringLoopValue()
Dim StoreLoopValue(15) As Integer

    For I = 1 To 16
        StoreLoopValue(I - 1) = I
    Next I

    For I = 0 To 15
        MsgBox StoreLoopValue(I)
    Next I
End Function

Hope this helps...
Regards,
 
Thanks this helps a lot, is there something similar for storing and retrieving text from String variables ?
 
Concept is same, just make some small changes....

Code:
Public Function StoringLoopValue()
Dim StoreLoopValue(15) As String

    For I = 1 To 16
        StoreLoopValue(I - 1) = me.sometext
    Next I

    For I = 0 To 15
        MsgBox StoreLoopValue(I)
    Next I
End Function

Hope this helps you...
Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top