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. how can change the LeftMost dimension of an array

how can change the LeftMost dimension of an array

Scheduled Pinned Locked Moved Visual Basic
questiondata-structureshelptutorial
5 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.
  • R Offline
    R Offline
    Rupesh Kumar Swami
    wrote on last edited by
    #1

    hi all i want to change the leftmost dimension of a two - dimensional array. but redim statement does not change the Left Most dimension. For example i declare a two-dimensional array as following Dim WrappingItemInfo(0, 4) As String after that i write following statement at particular condition ReDim Preserve WrappingItemInfo(1, 4) but above statement give error "'ReDim' can only change the rightmost dimension.". so how can i change the leftmost dimension of an array ?

    Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

    C 1 Reply Last reply
    0
    • R Rupesh Kumar Swami

      hi all i want to change the leftmost dimension of a two - dimensional array. but redim statement does not change the Left Most dimension. For example i declare a two-dimensional array as following Dim WrappingItemInfo(0, 4) As String after that i write following statement at particular condition ReDim Preserve WrappingItemInfo(1, 4) but above statement give error "'ReDim' can only change the rightmost dimension.". so how can i change the leftmost dimension of an array ?

      Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

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

      set WrappingItemInfo(1) to be a new array of four elements. This would work in C#, should work in VB.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      R 1 Reply Last reply
      0
      • C Christian Graus

        set WrappingItemInfo(1) to be a new array of four elements. This would work in C#, should work in VB.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        R Offline
        R Offline
        Rupesh Kumar Swami
        wrote on last edited by
        #3

        sir, thanks for your response but i does not properly get you can you explain it bit more with code(whether in c# or vb) one more thing. in my previous post, i simply give a example. In real condition, Leftmost dimension of an array is increased every time by one when a particular condition is found.

        Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

        C G 2 Replies Last reply
        0
        • R Rupesh Kumar Swami

          sir, thanks for your response but i does not properly get you can you explain it bit more with code(whether in c# or vb) one more thing. in my previous post, i simply give a example. In real condition, Leftmost dimension of an array is increased every time by one when a particular condition is found.

          Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

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

          int [,] n = new int[5,5](); n[0] = new int[5](); something like that

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          1 Reply Last reply
          0
          • R Rupesh Kumar Swami

            sir, thanks for your response but i does not properly get you can you explain it bit more with code(whether in c# or vb) one more thing. in my previous post, i simply give a example. In real condition, Leftmost dimension of an array is increased every time by one when a particular condition is found.

            Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            You should use a dynamic collection instead of an array, like a List(Of String()). An array can't be resized, so what the ReDim command does is to create a new array, and copy all data from the old array to the new array. It can get pretty expensive as the array grows...

            Despite everything, the person most likely to be fooling you next is yourself.

            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