View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bill Renaud Bill Renaud is offline
external usenet poster
 
Posts: 417
Default How to read a string from a variant array ?

You don't need to specify the size of the array if you are going to use
the Array function to assign the values, since the compiler can figure
the size out at design time. You might need to use a REDIM later in the
program, if you add more values.

Public Sub Test()
Dim MyArray As Variant

MyArray = Array("help", 1, 2, 3, 4)

MsgBox "Check: " & CStr(MyArray(0))
End Sub

I also changed the "+" to a "&" in your MsgBox statement, since it is
better practice when using strings, even though it is technically not
required.
(Someday you will have 2 variables that are supposed to be strings, but
are numbers, and addition will be performed instead.)
--
Regards,
Bill Renaud