get every 2 parts of array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • iBeaver
    New Member
    • Jan 2009
    • 2

    get every 2 parts of array

    Im trying to get every 2nd part of my array() for example..

    dim arr() as string
    dim words as string

    words = "Hello there, My Name Is Beaver"
    arr() = split(words, " ")

    i want to create a loop to get the words: "There, name beaver"

    so its like every 2 parts of the array()

    Thankyou
  • jmeirow
    New Member
    • Jan 2009
    • 2

    #2
    every two bytes of array

    set up a loop counter and test the loop variable using the modulus operator (%) with a value of 2. Suppose your loop variable is 'i'.

    if (i % 2 ==0)
    {
    // this is every other element
    }

    Comment

    • iBeaver
      New Member
      • Jan 2009
      • 2

      #3
      This is visual basic?

      Not javascript or java?

      Comment

      • jmeirow
        New Member
        • Jan 2009
        • 2

        #4
        every other part of array

        VB has a modulus operator. I think it is '%' as well.

        Comment

        Working...