Results 1 to 6 of 6

Thread: passing USER Defined TYPEs

  1. #1
    Guest

    Post

    Is there something special you have to do to pass a variable of user defined type?
    thanks

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Take an account that User Defined Type cannot be passed ByVal.

  3. #3
    Guest

    Post

    i still get "type mismatch" error
    here is my call:
    LoadMemory (smlProg)

    and here is my function:
    Private Function LoadMemory(ByRef smlProg As SML)

    End Function

    keep in mind my user defined type is called SML

    thanks

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    I've tried to recreate your function and it is working propertly. Here's an example:

    Code:
    Private Type SML
        strTemp As String
        intTemp As Integer
    End Type
    
    Private Function LoadMemory(ByRef smlProg As SML)
        smlProg.intTemp = 5
        MsgBox smlProg.intTemp
    End Function
    
    
    
    Private Sub Command1_Click()
        Dim utTemp As SML
        
        Call LoadMemory(utTemp)
    End Sub

  5. #5
    Guest

    Post

    that worked. I guess it was the call loadmemory. and the fact i wanted to send it and return it by value. lesson learned. thanks.

    on another note, i could send a normal variable byRef correct?

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    For a simple variable you can send it either ByRef or ByVal.

Posting Permissions

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



Click Here to Expand Forum to Full Width