Converting an array from integer to string

G

Guest

Hi All,

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

kd
 
K

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

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

Hi All,

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

kd
 
C

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
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
Why not just dim arStr(arInt.Lenght) as String?

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

Cor Ligthert

Herfried,
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
 

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

Top