The problem appears to be the font for the quote marks. I copied the code
you posted and got the results you described. When I changed the quote marks
on the months, it worked. Below is the code with the courier font quote
marks. Try it.
Sub assignArray()
Dim myArr() As Variant
ReDim myArr(5) As Variant
myArr(1) = "Jan"
myArr(2) = "Feb"
myArr(3) = "Mar"
myArr(4) = "Apr"
myArr(5) = "May"
MsgBox myArr(1)
ReDim Preserve myArr(6)
myArr(6) = "Jun"
MsgBox myArr(1) + "-" + myArr(2) + "-" + myArr(3) + "-" + myArr(4) _
+ "-" + myArr(5) + "-" + myArr(6)
End Sub
"Phillip M. Feldman" wrote:
> The following simple program is supposed to display one message box
> containing the string "Jan", and a second one containing six month names
> separated by dashes. At least one person reports getting this result from the
> code, but when I run it on my two laptop computers, the first message box is
> empty, and the second contains only the five dashes (no month names). All of
> these are Windows XP PCs running Excel 2003. Any suggestions as to why this
> is happening will be greatly appreciated.
>
> Option Base 1
> Dim Arr() As String
>
> Sub assignArray()
> ReDim Arr(5)
>
> Arr(1) = “Jan”
> Arr(2) = “Feb”
> Arr(3) = “Mar”
> Arr(4) = “Apr”
> Arr(5) = “May”
>
> MsgBox Arr(1)
>
> ReDim Preserve Arr(6)
>
> Arr(6) = “Jun”
>
> MsgBox Arr(1) + "-" + Arr(2) + "-" + Arr(3) + "-" + Arr(4) + "-" + Arr(5)
> + "-" + Arr(6)
> End Sub
|