Converting an array from integer to string

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

Guest

Hi All,

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

kd
 
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
 
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
 
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.
 
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
 
Back
Top