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. General Programming
  3. Visual Basic
  4. array

array

Scheduled Pinned Locked Moved Visual Basic
data-structures
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.
  • W Offline
    W Offline
    WhiteGirl23
    wrote on last edited by
    #1

    Hi. I have this code: for i as integer=0 to array.lenght-1 if array(i)=value1 then var=true end if if var=true then .... next I need to set the value1 on the first position of the array and the first position of the array must be set on the last position of the array. I don't have any idea. thanks

    C C 2 Replies Last reply
    0
    • W WhiteGirl23

      Hi. I have this code: for i as integer=0 to array.lenght-1 if array(i)=value1 then var=true end if if var=true then .... next I need to set the value1 on the first position of the array and the first position of the array must be set on the last position of the array. I don't have any idea. thanks

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      WhiteGirl23 wrote:

      I need to set the value1 on the first position of the array and the first position of the array must be set on the last position of the array.

      In that order? If you do it in that order then value1 will be set on the first and last positions of the array. Try this:

      array(array.Length - 1) = array(0)
      array(0) = value1


      -- Always write code as if the maintenance programmer were an axe murderer who knows where you live. Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ... * Reading: SQL Bits My website

      W 1 Reply Last reply
      0
      • C Colin Angus Mackay

        WhiteGirl23 wrote:

        I need to set the value1 on the first position of the array and the first position of the array must be set on the last position of the array.

        In that order? If you do it in that order then value1 will be set on the first and last positions of the array. Try this:

        array(array.Length - 1) = array(0)
        array(0) = value1


        -- Always write code as if the maintenance programmer were an axe murderer who knows where you live. Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ... * Reading: SQL Bits My website

        W Offline
        W Offline
        WhiteGirl23
        wrote on last edited by
        #3

        no.isn't good. I want to keep all the values of the array. In array(array.length-1)=must keep the first position of the vector before I make array(0)=value1.

        1 Reply Last reply
        0
        • W WhiteGirl23

          Hi. I have this code: for i as integer=0 to array.lenght-1 if array(i)=value1 then var=true end if if var=true then .... next I need to set the value1 on the first position of the array and the first position of the array must be set on the last position of the array. I don't have any idea. thanks

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Please always paste the actual code, in case a typo changes the context of something. How do you mean ? You want to swap the first and last items ?

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          W 1 Reply Last reply
          0
          • C Christian Graus

            Please always paste the actual code, in case a typo changes the context of something. How do you mean ? You want to swap the first and last items ?

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            W Offline
            W Offline
            WhiteGirl23
            wrote on last edited by
            #5

            example: I have a string :123#123.123#(local) I split this string: array()=string.split("#") I'm looking for a value on this array.I take (local) I found the position of this value:array((2). I want to move array(2) on the first position of the array,but I don't want to loose elements of the array,and the last position of the array must be=123. Something like this: string=(local)#123.123#123 Thanks.

            C 1 Reply Last reply
            0
            • W WhiteGirl23

              example: I have a string :123#123.123#(local) I split this string: array()=string.split("#") I'm looking for a value on this array.I take (local) I found the position of this value:array((2). I want to move array(2) on the first position of the array,but I don't want to loose elements of the array,and the last position of the array must be=123. Something like this: string=(local)#123.123#123 Thanks.

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              So you want to *swap* the elements. So you do this: dim o as object = array(0) array(0) = array(array.Length = 1) array(array.Length - 1) = o

              Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              W 1 Reply Last reply
              0
              • C Christian Graus

                So you want to *swap* the elements. So you do this: dim o as object = array(0) array(0) = array(array.Length = 1) array(array.Length - 1) = o

                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                W Offline
                W Offline
                WhiteGirl23
                wrote on last edited by
                #7

                thanks. hope will work.

                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