Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initialising/Using an array of String 1

Status
Not open for further replies.

paradoxdetected

Programmer
Aug 2, 2009
4
GB
Hi guys,

Sorry for asking a stupid question, but I've got to the point where I have the data I need, ocurring in a For Each loop in VB 2008.

Now, can someone help me initialise an array of String andsave the data to it?

Thanks so much

Paradox Detected
 
Arrays are static. You can increase their capacity (allocate more space) but i wouldnt recommend it.
Instead use an ArrayList to save objects, or use a List of "X" to save "X". "X" are datatypes, like string, integers etc.

Private a_name_here As New List(Of String)

a_name_here.Add("string1")
a_name_here.Add("string2")
 
Just as an alternate way usually any object you use in a for each is going to have the count of that object. You can always initialize it with the objects .Count, .Items.Count, or .Length. Generally I just use a generic Collection or StringCollection in this instance, but just wanted to put forth the alternative.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top