|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
for each loop, grab next item
for each item in A
is there a way in this loop to grab item, do arithmatic, then grab the next element in the array without going through the loop agian? I want to do 2 at a time and just thought it would be nicer if there was a way rather than having to deal with an integer and checking whether it was odd or even... |
|
#2
|
||||
|
||||
|
Code:
For cnt = 0 To 10
val1 = ary(cnt)
cnt = cnt + 1
If cnt <= 10 Then
val2 = ary(cnt)
End If
MsgBox "Val(" & (cnt - 1) & ") = " & val1 & vbCrLf _
& "Val(" & cnt & " = " & val2
Next cnt
|
|
#3
|
|||
|
|||
|
dear onslaught's help desk...
Yea, after seeing that i feel kinda stupid, there's an array length attribute isn't there.... damnit
i was thinking i had to use for each X in ARRAY, but i guess an even easier what would be the FOR cnt 0 to array.length-1 blah cnt=cnt+1 blah next cnt I did a split on a 2 column comma separated excel cvs file, so they'll always be in pairs but in anycase, i guess that means there isn't a way to do Array(item+1) for the FOR EACH method then huh? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > for each loop, grab next item |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|