We help IT Professionals succeed at work.
Get Started

Using arrays

Tom_Hickerson
on
213 Views
Last Modified: 2017-11-27
If I want to have an array of strings that I can add to.  How can I do this without keeping track of every time I add a new string.  

So what I have been doing is this...
  Dim myStrings(1000) As String
  Dim myStringCount As Integer


Then while the program is doing its sorting work
   If Not myStrings.Contains(pair.Primary) Then
                myStrings(myStringCount) = pair.Primary
              myStringCount  = myStringCount + 1
    End If

Then when I display them
I do a for loop using myStringCount to display each item
     For i = 0 To myStringCount - 1
            ListBox1.Items.Add(MyStrings(i))
        Next



I'm sure there is a more efficient way.  How would you guys do this?
Comment
Watch Question
Sr.Software Engineer
Commented:
This problem has been solved!
Unlock 3 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE