By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,693 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,693 IT Pros & Developers. It's quick & easy.

arrays of integers

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
--
Gerry O'Brien [MVP]
Visual Basic .NET(VB.NET)


"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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

Nov 21 '05 #2

P: n/a
thanks very much.

"Gerry O'Brien [MVP]" wrote:
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
--
Gerry O'Brien [MVP]
Visual Basic .NET(VB.NET)


"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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


Nov 21 '05 #3

P: n/a
"Gerry O'Brien [MVP]" <gerry dot obrien at gmail dot com> schrieb:
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... ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #4

P: n/a
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 [MVP]" <gerry dot obrien at gmail dot com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
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
--
Gerry O'Brien [MVP]
Visual Basic .NET(VB.NET)


"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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


Nov 21 '05 #5

P: n/a
Me and array counting have never gotten along. You would think that after
this long, I could get it right. Alas, no such luck. ;-)

--
Gerry O'Brien MCT, MCDBA, MCSD
Visual Developer .NET MVP
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:OE**************@TK2MSFTNGP09.phx.gbl...
"Gerry O'Brien [MVP]" <gerry dot obrien at gmail dot com> schrieb:
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... ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.