Connecting Tech Pros Worldwide Help | Site Map

arrays of integers

rodchar
Guest
 
Posts: n/a
#1: Nov 21 '05
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

Gerry O'Brien [MVP]
Guest
 
Posts: n/a
#2: Nov 21 '05

re: arrays of integers


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" <rodchar@discussions.microsoft.com> wrote in message
news:FABF8998-071E-4BE3-9E73-D09B06B28873@microsoft.com...[color=blue]
> 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
>[/color]


rodchar
Guest
 
Posts: n/a
#3: Nov 21 '05

re: arrays of integers


thanks very much.

"Gerry O'Brien [MVP]" wrote:
[color=blue]
> 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" <rodchar@discussions.microsoft.com> wrote in message
> news:FABF8998-071E-4BE3-9E73-D09B06B28873@microsoft.com...[color=green]
> > 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
> >[/color]
>
>
>[/color]
Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#4: Nov 21 '05

re: arrays of integers


"Gerry O'Brien [MVP]" <gerry dot obrien at gmail dot com> schrieb:[color=blue]
> 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[/color]

Don't forget to add the last item here... ;-).

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


Nick Hall
Guest
 
Posts: n/a
#5: Nov 21 '05

re: arrays of integers


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:%23HC9oJ9pEHA.376@TK2MSFTNGP14.phx.gbl...[color=blue]
> 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" <rodchar@discussions.microsoft.com> wrote in message
> news:FABF8998-071E-4BE3-9E73-D09B06B28873@microsoft.com...[color=green]
>> 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
>>[/color]
>
>[/color]


Gerry O'Brien [MVP]
Guest
 
Posts: n/a
#6: Nov 21 '05

re: arrays of integers


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]" <hirf.nosp@m.activevb.de> wrote in message
news:OE7DWa9pEHA.1988@TK2MSFTNGP09.phx.gbl...[color=blue]
> "Gerry O'Brien [MVP]" <gerry dot obrien at gmail dot com> schrieb:[color=green]
>> 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[/color]
>
> Don't forget to add the last item here... ;-).
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>
>
>[/color]


Closed Thread


Similar Visual Basic .NET bytes