Home All Groups Group Topic Archive Search About

Converting an array from integer to string

Author
14 May 2005 8:09 AM
kd
Hi All,

How to convert a one dimensional integer array to a one dimensional array of
type string?

kd

Author
14 May 2005 10:28 AM
Ken Tucker [MVP]
Hi,



        You have to manually convert it.



Dim arInt(10) As Integer

Dim arStr() As String

ReDim arStr(arInt.GetUpperBound(0))

For x As Integer = 0 To arInt.GetUpperBound(0)

arInt(x) = x

Next

For y As Integer = 0 To arInt.GetUpperBound(0)

arStr(y) = arInt(y).ToString

Next



Ken

---------------

"kd" <k*@discussions.microsoft.com> wrote in message
news:55BD973E-B2D2-459D-BF37-20D5A4CDF537@microsoft.com...
Hi All,

How to convert a one dimensional integer array to a one dimensional array of
type string?

kd
Author
14 May 2005 11:03 AM
kd
Thanks Ken.

Regards,
kd.

Show quoteHide quote
"Ken Tucker [MVP]" wrote:

> Hi,
>
>
>
>         You have to manually convert it.
>
>
>
> Dim arInt(10) As Integer
>
> Dim arStr() As String
>
> ReDim arStr(arInt.GetUpperBound(0))
>
> For x As Integer = 0 To arInt.GetUpperBound(0)
>
> arInt(x) = x
>
> Next
>
> For y As Integer = 0 To arInt.GetUpperBound(0)
>
> arStr(y) = arInt(y).ToString
>
> Next
>
>
>
> Ken
>
> ---------------
>
> "kd" <k*@discussions.microsoft.com> wrote in message
> news:55BD973E-B2D2-459D-BF37-20D5A4CDF537@microsoft.com...
> Hi All,
>
> How to convert a one dimensional integer array to a one dimensional array of
> type string?
>
> kd
>
>
>
Author
14 May 2005 11:25 AM
Herfried K. Wagner [MVP]
"Ken Tucker [MVP]" <vb***@bellsouth.net> schrieb:
> Dim arStr() As String
>
> ReDim arStr(arInt.GetUpperBound(0))

Why not just 'Dim arStr(arInt.GetUpperBound(0)) As String'?

Show quoteHide quote
:-)

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
14 May 2005 11:48 AM
Cor Ligthert
> Why not just 'Dim arStr(arInt.GetUpperBound(0)) As String'?

Why not just dim arStr(arInt.Lenght) as String?

After 2 minutes looking at it, I saw that that was the only improvement you
did.

:-)

Cor
Author
14 May 2005 12:27 PM
Herfried K. Wagner [MVP]
"Cor Ligthert" <notmyfirstn***@planet.nl> schrieb:
>> Why not just 'Dim arStr(arInt.GetUpperBound(0)) As String'?
>
> Why not just dim arStr(arInt.Lenght) as String?

Because it will create an array that has 'Length' + 1 elements, which is not
desired.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
14 May 2005 5:11 PM
Cor Ligthert
Herfried,

>>> Why not just 'Dim arStr(arInt.GetUpperBound(0)) As String'?
>>
>> Why not just dim arStr(arInt.Lenght) as String?
>
> Because it will create an array that has 'Length' + 1 elements, which is
> not desired.
>
I have a great tip for you.

Why not just dim arStr(arInt.Lenght - 1) as String?

I forgot that - 1, I would have expected from you that you had seen this,
however I like those answers as you give now. Makes me smilling.

:-)

Cor