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. Arrays in VB.Net

Arrays in VB.Net

Scheduled Pinned Locked Moved Visual Basic
csharpalgorithmsdata-structurestutorial
6 Posts 5 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
    Rip V Winkle
    wrote on last edited by
    #1

    I am programing a windows app (much like my console app talked about earlier in the forums) such as this. User inputs number Number is stored into an array there are commands the user can use to print sort and other such things. I do not want to use the arraylist function. I want to do this using just using array as such: Dim array1(3) as string I'm not sure how to add items to the array. In all my searching I only found information on the Arraylist. If anyone can Point me in the right direction. "Doko ni datte, hito wa tsunagatte iru." -Lain

    N 1 Reply Last reply
    0
    • R Rip V Winkle

      I am programing a windows app (much like my console app talked about earlier in the forums) such as this. User inputs number Number is stored into an array there are commands the user can use to print sort and other such things. I do not want to use the arraylist function. I want to do this using just using array as such: Dim array1(3) as string I'm not sure how to add items to the array. In all my searching I only found information on the Arraylist. If anyone can Point me in the right direction. "Doko ni datte, hito wa tsunagatte iru." -Lain

      N Offline
      N Offline
      Nick Seng
      wrote on last edited by
      #2

      Do you mean to assign objects to the array, simply do this

      array1(0) = "Hello"
      array1(1) = "world"

      If you mean to increase the capacity of the array, use the Redim keyword

      Redim Preserve array1(10)
      array1(9) = "Bye"


      Sig Under Construction. Visit back later. Support Bone

      R 1 Reply Last reply
      0
      • N Nick Seng

        Do you mean to assign objects to the array, simply do this

        array1(0) = "Hello"
        array1(1) = "world"

        If you mean to increase the capacity of the array, use the Redim keyword

        Redim Preserve array1(10)
        array1(9) = "Bye"


        Sig Under Construction. Visit back later. Support Bone

        R Offline
        R Offline
        Rip V Winkle
        wrote on last edited by
        #3

        I want to assign objects to the array. However I need to do this dynamically as they type information in. I can't get the code right for the program to add the new string to the end of the array. :(

        D C 2 Replies Last reply
        0
        • R Rip V Winkle

          I want to assign objects to the array. However I need to do this dynamically as they type information in. I can't get the code right for the program to add the new string to the end of the array. :(

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Post a code snippet so we can see what you are doing. The two methods above work perfectly for String types also, so we're not getting all the details we need to know to answer your question. RageInTheMachine9532

          M 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Post a code snippet so we can see what you are doing. The two methods above work perfectly for String types also, so we're not getting all the details we need to know to answer your question. RageInTheMachine9532

            M Offline
            M Offline
            Mike Ellison
            wrote on last edited by
            #5

            So you're looking to dynamically increase the size of the array? If so, the earlier suggestion of Redim should work for you. You may want to look at the ArrayList class in the .Net Documentation anyway - the Add method makes it easy to work with a dynamically increasing list, and there are CopyTo and ToArray methods if you need to convert it to an actual Array object.

            1 Reply Last reply
            0
            • R Rip V Winkle

              I want to assign objects to the array. However I need to do this dynamically as they type information in. I can't get the code right for the program to add the new string to the end of the array. :(

              C Offline
              C Offline
              CybrWeez
              wrote on last edited by
              #6

              redim preserve numarray(size) numarray(ubound(numarray)) = newobject size += 1

              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