Re: Array Type Mismatch



Hi,


Your function return an array of string and you try to fit this array inside
a container devised to hold just a single string (I assume strArray is dim
as String(), not as Object() ).

=======================
Public Sub Void()
Dim array1(1 To 2) As String
Dim array2() As String
Dim array3(1 To 2) As Variant
Dim array4() As String

array2 = Split("aaa bbb ccc")
array3(1) = array2
array4 = array2
array1(1) = array2


End Sub
========================


the last executable line produces your mismatch, comment it and every thing
is fine.

You can:
assign an array of string to a redim-ensionable array of string
(array2 = split(...) )
assign an array of string to a variant or an object container
(array3(1) = array2)
assign an array of string to a redim-ensionable array of string (
array4=array2)

You cannot:
assign an array to a non-variant non-object container
assign an array to a non-redim-ensionable array: array3=array1
would fail, even if both are dimmed as array (1 to 2) and even if a variant
can hold a string.


That is assuming you use VBA6. Previous versions (Access 97 and older) don't
necessary play the same game, and don't have built-in functions like split.


Hoping it may help,
Vanderghast, Access MVP


"State Troopers" <StateTroopers@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F88EA92C-26F6-4759-95C9-ABEABAF313FC@xxxxxxxxxxxxxxxx
Hi.
I am having a problem with one of my functions.

here is the code:


strArray(i) = TextBoxGetLines(txtDone, False)

-------


Function TextBoxGetLines(tb As TextBox, Optional KeepHardLineBreaks As
Boolean) As String()

TextBoxGetLines = result()

End Function




Am I passing the variables into the function correctly?

Thanks.
-State





.



Relevant Pages

  • RE: Follow up question. Get value of closed file.
    ... You havve to access each member of the array ... Dim ReturnData as Variant ... SourceSheet As String, _ ... Dim rsData As Object ...
    (microsoft.public.excel.programming)
  • Re: Need help with SeriesCollection Object Please !
    ... Why did you use 4 Elements in your Array and then the use of the Exit ... Function GetSourceSheet(sFmla As String, sWSname, sFile As String) As ... Dim i As Long ... ran my code on certain other charts sometimes it would return ...
    (microsoft.public.excel.programming)
  • Re: Searching for best matches in string query
    ... looped through my recordset as an array counting the matches. ... 'Receives an array to be searched and the string value containing all the ... Dim arrData() ' As String ... Dim iLeftcur, iRightCur, iPivot, iTemp As Long ...
    (microsoft.public.access.queries)
  • RE: ReDim Preserve code almost working
    ... specifying beginning and ending elements. ... SegList will, however, accept a zero-based array (because Option Base 1 does ... Optional iEnd As Long = -1) As String() ... Dim tmp() As String ...
    (microsoft.public.vb.general.discussion)
  • Re: Sorting a variant array
    ... Dim tempList As Variant ... Dim testerList() As String ... Function sortTesters(rangeName As String) ... column range--but even that ends up as a x-rows by 1 column array. ...
    (microsoft.public.excel.programming)