+ Reply to Thread
Results 1 to 2 of 2

Help: Compile error: type mismatch: array or user defined type expected

  1. #1
    lvcha.gouqizi
    Guest

    Help: Compile error: type mismatch: array or user defined type expected

    Hi there,

    I defined a type named testArray and student() as an array of testArray
    type. The compiler always reports "array or user defined type expected"
    compile error no matter how I give the array parameter to the function.

    Public Type testArray
    age() As Integer
    End Type


    Sub calling()
    Dim student() As testArray
    called (student)
    End Sub

    Sub called(ByRef temparray() As testArray)
    temparray(1).age(1) = 20
    End Sub

    What's wrong with called(student)?

    I also tried called(student()). It doesn't work either.


  2. #2
    Jim Thomlinson
    Guest

    RE: Help: Compile error: type mismatch: array or user defined type exp

    First things first. Get rid of the brackets for the Called sub. They will
    mess things up. You can either have

    Call Called(student())
    or
    Called Sutdent()

    Secondly you need to define the array sizes. Either explicitly when they are
    created or through a redim

    Public Type testArray
    age(5) As Integer
    End Type


    Sub calling()
    Dim student(10) As testArray

    called student()
    End Sub

    Sub called(ByRef temparray() As testArray)
    temparray(1).age(1) = 20
    End Sub
    --
    HTH...

    Jim Thomlinson


    "lvcha.gouqizi" wrote:

    > Hi there,
    >
    > I defined a type named testArray and student() as an array of testArray
    > type. The compiler always reports "array or user defined type expected"
    > compile error no matter how I give the array parameter to the function.
    >
    > Public Type testArray
    > age() As Integer
    > End Type
    >
    >
    > Sub calling()
    > Dim student() As testArray
    > called (student)
    > End Sub
    >
    > Sub called(ByRef temparray() As testArray)
    > temparray(1).age(1) = 20
    > End Sub
    >
    > What's wrong with called(student)?
    >
    > I also tried called(student()). It doesn't work either.
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1