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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Add an element to an Array

Add an element to an Array

Scheduled Pinned Locked Moved Visual Basic
questioncsharpdata-structures
3 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.
  • D Offline
    D Offline
    directred
    wrote on last edited by
    #1

    In VB.Net, is there a simple way of adding another line onto an array. If not what is the best way?

    U D 2 Replies Last reply
    0
    • D directred

      In VB.Net, is there a simple way of adding another line onto an array. If not what is the best way?

      U Offline
      U Offline
      User 1884058
      wrote on last edited by
      #2

      If adding another lines means adding another index to the array, then you can use a simple Redim Preserve ArrayName(NumberofIndexes). If your array had one element then NumberOfIndexes should equal 2. Don't know if this helps you much

      1 Reply Last reply
      0
      • D directred

        In VB.Net, is there a simple way of adding another line onto an array. If not what is the best way?

        D Offline
        D Offline
        Dave Doknjas
        wrote on last edited by
        #3

        ReDim Preserve for arrays, but you might want to look at ArrayList or StringCollection (or many other .NET collections). The collections offer good performance when adding new items (better than ReDim Preserve), but have other aspects that may reduce performance, so try ArrayList, and if your items are always strings, try StringCollection. Also, if you have to do lookups by key on the list then Hashtable is great. David Anton Tangible Software Solutions www.tangiblesoftwaresolutions.com Home of: Instant C#: VB.NET to C# Converter Instant VB: C# to VB.NET Converter Instant J#: VB.NET to J# Converter

        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