Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ArrayList looping

ArrayList looping

Scheduled Pinned Locked Moved ASP.NET
tutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sarfaraj Ahmed
    wrote on last edited by
    #1

    Hello Everybody My ArrayList (name aList) is Follows: aList(0) = 4, 5 aList(1) = 6, 7 aList(2) = 8, 9 What I want to call function as below:

    Dim aa() As String

    for i = 0 to aList.Count - 1

    aa(i) = myFunction (aList(0,0), aList(0,1), aList(1,0), aList(1,1))

    Next

    Every Single time myFunction will take 4 values from aList For Example: i = 0 , will take value from aList(0) and aList(1) i = 1 , will take value from aList(0) and aList(2) i = 2 , will take value from aList(1) and aList(2) Please tell me some logic Thanks Sarfaraj

    Sarfarj Ahmed

    Y K 2 Replies Last reply
    0
    • S Sarfaraj Ahmed

      Hello Everybody My ArrayList (name aList) is Follows: aList(0) = 4, 5 aList(1) = 6, 7 aList(2) = 8, 9 What I want to call function as below:

      Dim aa() As String

      for i = 0 to aList.Count - 1

      aa(i) = myFunction (aList(0,0), aList(0,1), aList(1,0), aList(1,1))

      Next

      Every Single time myFunction will take 4 values from aList For Example: i = 0 , will take value from aList(0) and aList(1) i = 1 , will take value from aList(0) and aList(2) i = 2 , will take value from aList(1) and aList(2) Please tell me some logic Thanks Sarfaraj

      Sarfarj Ahmed

      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #2

      your example does not give a complete picture, or does it? Do you have only 3 items in your array or can it be more? ( I'm inclining to think more) what is the correlation between the example you have with an array of 10 items? will double loop work for your?

      for i = 0 to aList.Count - 2
      for j = i+1 to aList.Count - 1
      aa(i) = myFunction aList(i), aList(j)

      this will produce something like this

      aList(0) , aList(1)
      aList(0) , aList(2)
      aList(1) , aList(2)

      Yusuf

      S 2 Replies Last reply
      0
      • Y Yusuf

        your example does not give a complete picture, or does it? Do you have only 3 items in your array or can it be more? ( I'm inclining to think more) what is the correlation between the example you have with an array of 10 items? will double loop work for your?

        for i = 0 to aList.Count - 2
        for j = i+1 to aList.Count - 1
        aa(i) = myFunction aList(i), aList(j)

        this will produce something like this

        aList(0) , aList(1)
        aList(0) , aList(2)
        aList(1) , aList(2)

        Yusuf

        S Offline
        S Offline
        Sarfaraj Ahmed
        wrote on last edited by
        #3

        Dear Yusuf Thanks for your reply. There will be three items into aList. Like below: aList(0) will keep two values 7 and 8 aList(1) will keep two values 4 and 6 aList(2) will keep two values 5 and 9 I have to call a function which will take 4 values from aList (every single aList row keep 2 values) First Time I have to send value from aList(0) and aList(1) Second Time I have to send value from aList(0) and aList(2) Third Time I have to send value from aList(1) and aList(2) Thanks

        Sarfarj Ahmed

        1 Reply Last reply
        0
        • Y Yusuf

          your example does not give a complete picture, or does it? Do you have only 3 items in your array or can it be more? ( I'm inclining to think more) what is the correlation between the example you have with an array of 10 items? will double loop work for your?

          for i = 0 to aList.Count - 2
          for j = i+1 to aList.Count - 1
          aa(i) = myFunction aList(i), aList(j)

          this will produce something like this

          aList(0) , aList(1)
          aList(0) , aList(2)
          aList(1) , aList(2)

          Yusuf

          S Offline
          S Offline
          Sarfaraj Ahmed
          wrote on last edited by
          #4

          more senario for i = 0 to aList.Count - 2 j= i + 1 to aList.Count - 1 aa(i) = myFunction (aList(0,0), aList(0,1), aList(1,0), aList(1,1) like this

          Sarfarj Ahmed

          Y 1 Reply Last reply
          0
          • S Sarfaraj Ahmed

            Hello Everybody My ArrayList (name aList) is Follows: aList(0) = 4, 5 aList(1) = 6, 7 aList(2) = 8, 9 What I want to call function as below:

            Dim aa() As String

            for i = 0 to aList.Count - 1

            aa(i) = myFunction (aList(0,0), aList(0,1), aList(1,0), aList(1,1))

            Next

            Every Single time myFunction will take 4 values from aList For Example: i = 0 , will take value from aList(0) and aList(1) i = 1 , will take value from aList(0) and aList(2) i = 2 , will take value from aList(1) and aList(2) Please tell me some logic Thanks Sarfaraj

            Sarfarj Ahmed

            K Offline
            K Offline
            Kunal Pawar
            wrote on last edited by
            #5

            Array list is nothing but collections of item, you can not store 2 value on same index.

            Y 1 Reply Last reply
            0
            • K Kunal Pawar

              Array list is nothing but collections of item, you can not store 2 value on same index.

              Y Offline
              Y Offline
              Yusuf
              wrote on last edited by
              #6

              Kunal Pawar wrote:

              Array list is nothing but collections of item, you can not store 2 value on same index.

              So, if it is a collection of item, can't you have an item composed of many things which is stored on single index. :^)

              ' Creates and initializes a new ArrayList.
              Dim myAL As New ArrayList()
              myAL.Add("1,2")
              myAL.Add("3,4")
              myAL.Add("5,6")

              I'm not saying this is the most efficient way of doing it, just showing you that you can store more than one item in an index, by creating collection.

              Yusuf

              1 Reply Last reply
              0
              • S Sarfaraj Ahmed

                more senario for i = 0 to aList.Count - 2 j= i + 1 to aList.Count - 1 aa(i) = myFunction (aList(0,0), aList(0,1), aList(1,0), aList(1,1) like this

                Sarfarj Ahmed

                Y Offline
                Y Offline
                Yusuf
                wrote on last edited by
                #7

                arrays[^]

                Yusuf

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups