arrays of integers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey all,

I have an array of numbers. What's the best way to get those numbers into
one text field semicolon delimited?

thanks ,
rodchar
 
Create a loop that will read through all of the items in the array and add
the item, plus the comma, to a stringbuilder object.

Dim retString As New StringBuilder

For intcounter As Integer = 0 To arrInts.Length - 2

retString.Append(arrInts(intcounter) & ", ")

Next
 
thanks very much.

Gerry O'Brien said:
Create a loop that will read through all of the items in the array and add
the item, plus the comma, to a stringbuilder object.

Dim retString As New StringBuilder

For intcounter As Integer = 0 To arrInts.Length - 2

retString.Append(arrInts(intcounter) & ", ")

Next
 
Alternatively, you can use the Microsoft.VisualBasic.Strings.Join function.
Something like the following: -

Dim test() As Integer = {1, 2, 3, 4, 5, 6}
Dim result As String = Join(ArrayList.Adapter(test).ToArray(), ";")

Unfortunately you can't pass an array of value types directly to a parameter
expecting an array of objects, hence the use of the ArrayList Adapter
method.

Nick Hall
 
Gerry O'Brien said:
Create a loop that will read through all of the items in the array and add
the item, plus the comma, to a stringbuilder object.

Dim retString As New StringBuilder

For intcounter As Integer = 0 To arrInts.Length - 2

retString.Append(arrInts(intcounter) & ", ")

Next

Don't forget to add the last item here... ;-).
 
Me and array counting have never gotten along. You would think that after
this long, I could get it right. Alas, no such luck. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

database records into an array 2
array in dataset 4
2 arrays into 1 2
An array and a datagrid 9
overriding array size 5
Array question 3
array bound listbox 2
I thought it was an easy question 7

Back
Top