Re: UDT Array Parameter

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Joel Whitehouse (joelwhitehouse_at_gmail.com)
Date: 12/21/04


Date: Tue, 21 Dec 2004 19:23:15 GMT


> The message tells the story. Move the Type definition into a standard
> module and make it Public.
I had already followed your advice at the time that I posted.

I realized what the problem was;

It looks like the array passing was already working - it appears that my
test function was *not* the late-bound function that the error message
was talking about.

Even though my Type declaration is public in a module, I still got the
same error message; apparently, the late-bound function is the IsArray()
function, which takes a variant and determines if it can be used as an
array.

However, since my function header already used an array that didn't need
to be tested, my call to IsArray() involved casting a UDT as a variant,
hence, the error message.

'Here's the code I used:

'-----------------------------------------------------
Private Sub Form_Load()
Dim test() As myTestType, b As Boolean
ReDim test(0 To 7)
b = TestFunc(test, 1)
End Sub

Private Function TestFunc(ItemArray() As myTestType,_
                ByVal ItemElement As Long) As Boolean

If Not IsArray(ItemArray) Then 'Uneccesary and invalid Call!!!!!!!!!
            Err.Raise 13, , "Type Mismatch"
        TestFunc = True
        Exit Function
End If
        MsgBox ItemArray(ItemElement).ThisNum
        MsgBox ItemArray(ItemElement).ThatNum
        TestFunc = True
End Function

'Module Code
Public Type myTestType
     ThisNum As Integer
     ThatNum As Integer
End Type

Lesson learned: When testing new coding techniques, "keep it simple,
stupid."

Thanks guys!

-Joel Whitehouse



Relevant Pages

  • Re: im so tired
    ... What is the error message? ... Add this below "Dim rst as DAO.Recordset" ... An Array? ... Private Sub cod_AfterUpdate ...
    (comp.databases.ms-access)
  • Re: memory problem, I guess
    ... If I use part of the data I'm getting the right transform. ... I searched the web and found that the error message is ... Below is the error message I'm getting when I increas my array size: ... trying to use (it would have been good to specify that)? ...
    (comp.lang.fortran)
  • Re: "Flex memory error" woes
    ... as the error message is not very helpful and the program ... which kept all allocated block pointers in an array and before ... NB I do let allocated arrays hold pointers - it seems to work although I ...
    (comp.sys.acorn.programmer)
  • Re: [RFC] [PATCH] 32-bit pointers in x86-64
    ... I continue to think that the error message 'initializer element ... extern char array; ... is incorrect - the compiler generally has no knowledge what 'array' is (it may ... sure I have an open bug for this, but the sad thing is that bugs like this ...
    (Linux-Kernel)
  • Re: memory problem, I guess
    ... If I use part of the data I'm getting the right transform. ... I searched the web and found that the error message is ... Below is the error message I'm getting when I increas my array size: ... trying to use (it would have been good to specify that)? ...
    (comp.lang.fortran)