ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Can one store a string in a Array element? (https://www.excelbanter.com/excel-discussion-misc-queries/139217-can-one-store-string-array-element.html)

[email protected]

Can one store a string in a Array element?
 
2003/2007

If I: Dim myArray(1 to 2) as long

myArray(1) = "+" does not work as I get a type mismatch.

I thought that array elements were like a Variable.

myArray(1) = 25 works fine

I know that one can initialize an array like array("a", "b")

Why can I not store a string to myArray(1)???

TIA EagleOne

JE McGimpsey

Can one store a string in a Array element?
 
Why can I not store a string to myArray(1)???

Because you dimension myArray as *long*, not *string*

Dim myArray(1 to 2) As String
myArray(1) = "+"


In article ,
wrote:

2003/2007

If I: Dim myArray(1 to 2) as long

myArray(1) = "+" does not work as I get a type mismatch.

I thought that array elements were like a Variable.

myArray(1) = 25 works fine

I know that one can initialize an array like array("a", "b")

Why can I not store a string to myArray(1)???

TIA EagleOne



All times are GMT +1. The time now is 03:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com