Re: Array Type Mismatch
- From: "Michel Walsh" <vanderghast@VirusAreFunnierThanSpam>
- Date: Tue, 2 May 2006 08:50:38 -0400
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
.
- Follow-Ups:
- Re: Array Type Mismatch
- From: State Troopers
- Re: Array Type Mismatch
- Prev by Date: Searching in Result set
- Next by Date: Re: How to tell how if a form is opened in Dialog mode
- Previous by thread: Searching in Result set
- Next by thread: Re: Array Type Mismatch
- Index(es):
Relevant Pages
|