gmaxey
07-19-2010, 08:01 PM
The little voice is telling me that I should know better than to ask, but I am going to ask anyway.
The sampling of code below shows how I could use a function to get the string data type elements for a small array.
Sub Test()
Dim myArr() As String
ReDim myArr(1, 1)
myArr = getMyArrData
MsgBox myArr(0, 0)
End Sub
Function getMyArrData() As Variant
Dim tempArr(1, 1) As String
tempArr(0, 0) = "Test 1"
tempArr(1, 0) = "Test 2"
tempArr(0, 1) = "Test 3"
tempArr(1, 1) = "Test 4"
getMyArrData = tempArr
End Function
It seems I stuck with using the "Variant" datatype for the function. What I am wondering is if there is not a more direct approach? I was thinking something like:
Function getMyArrData(1, 1) as String
getMyArrData(0, 0) = "Test 1"
getMyArrData(1, 0) = "Test 2"
...
...
End Function
... would work, but it certainly doesn't.
Thanks.
The sampling of code below shows how I could use a function to get the string data type elements for a small array.
Sub Test()
Dim myArr() As String
ReDim myArr(1, 1)
myArr = getMyArrData
MsgBox myArr(0, 0)
End Sub
Function getMyArrData() As Variant
Dim tempArr(1, 1) As String
tempArr(0, 0) = "Test 1"
tempArr(1, 0) = "Test 2"
tempArr(0, 1) = "Test 3"
tempArr(1, 1) = "Test 4"
getMyArrData = tempArr
End Function
It seems I stuck with using the "Variant" datatype for the function. What I am wondering is if there is not a more direct approach? I was thinking something like:
Function getMyArrData(1, 1) as String
getMyArrData(0, 0) = "Test 1"
getMyArrData(1, 0) = "Test 2"
...
...
End Function
... would work, but it certainly doesn't.
Thanks.