VB 6: passing an object as parameter to a function RRS feed

  • General discussion

  • Hello,

    Can anyone please help me with a small problem.
    I am using the visual basic 6.0 and I try to create a simple function
    that needs to have as a parameter an object and then to use the object passed as parameter.
    The simple example I can give to you is in C++:

    void Foo(CObject &object){
      // Here I can use the object

    or far more simple but not very recommended

    void Foo(CObject object){ // without (&) and pass the entire object, no problem if it is working
      // Here I can use the object

    in VB6 I do like this

    Public Function Foo(ByVal obj As Object)
    // Here I want o use the function.
    // The problem is that I have an error
    End Function

    Now when I try to use this function:

    Private Sub Command1_Click()
    Foo (Command1)
    End Sub

    I get this error:
    Compile Error:

    Type mismatch

    Than your help.

    • Changed type SJWhiteley Monday, September 15, 2008 1:48 PM VB6: Off Topic
    Monday, September 15, 2008 10:16 AM

All replies