Address arrays via a for next loop

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2009
Posts: 7
Reputation: smileyc is an unknown quantity at this point 
Solved Threads: 0
smileyc smileyc is offline Offline
Newbie Poster

Address arrays via a for next loop

 
0
  #1
May 20th, 2009
HI, I am sure that this has been asked before, but I can't seem to find the answer, so apologies for that.

I have 5 arrays, imaginatively named, array1 array2 etc. I want to operate on them via a for next loop. The pseudo code would look like this I guess :

  1. dim token as integer = 'something'
  2. dim array1 as integer {1,2,3,4,5}
  3. dim array2 as ineger {1,2,3,4,5}
  4. etc for rest of arrays
  5. for i as integer = 1 to 5
  6. if array(i,token) = 'something' then
  7. perform calculation
  8. end if
  9. next i
How would I code that so that it works please?
Thanks for all and any help.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 193
Reputation: jbisono is an unknown quantity at this point 
Solved Threads: 24
jbisono's Avatar
jbisono jbisono is offline Offline
Junior Poster

Re: Address arrays via a for next loop

 
0
  #2
May 20th, 2009
Hi, I do not really understand what is your goal with this code, first of all this line does not seem right to me.

dim token as integer = 'something'

but anyway i think what you want is this.

Dim token As Integer = 3
        Dim Array1(,) As Integer = {{1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}}
       
        For i As Integer = 0 To 1
            For a As Integer = 0 To 4
                If Array1(i, a) = token Then
                    TextBox1.Text += "Should Find Number 3 two times"
                End If
            Next a
        Next i

Regards
If your already resolved your issue, flag it as solved.
José Bisonó
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 396 | Replies: 1
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC