Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass PictureBox to DLL

Status
Not open for further replies.
Oct 5, 1999
105
0
0
GB
Is it possible to pass a PictureBox to a DLL?

When I try, I get Error 91

The full project will contain routines to draw various text and images, but I have created simple project1 with just a Command Button and a PictureBox and code
Code:
Option Explicit

Dim MyClass As Class1

Private Sub Command1_Click()

    Set MyClass.MyPicture = Picture1
    
End Sub

and a project2 ActiveX DLL with code
Code:
Option Explicit

Dim picPic As PictureBox


Public Property Set MyPicture(pPic As Object)
    
    Set picPic = pPic
    
End Property

Public Property Get MyPicture() As Object

    picPic.Print "Hello"

    Set MyPicture = picPic
    
End Property

When I click the Button, I get the error 91
Either I'm doing something silly, or missing some Reference, or it's not possible.

 
Er ... yuo probably don't want to try and pass a picturebox. Pass the Picture instead. Or, as previously mentioned, StdPicture.
 
Still get the same error 91

Changed test code to
Code:
Option Explicit
Public picPic As New StdPicture
Public MyClass As Class1

Private Sub Command1_Click()

    Set picPic = LoadPicture()
    Set MyClass.MyPicture = picPic
    
End Sub

and Class to
Code:
Option Explicit

Public picPic As New StdPicture

Private Sub Class_Initialize()
    Set picPic = LoadPicture()
End Sub

Public Property Set MyPicture(Pic As StdPicture)
    Set picPic = Pic
    
End Property

 
Have you read the error message?

You need an actual instance of Class1 ...

So just add

[tt]Set MyClass = New Class1[/tt]

or, slightly more dangerously, change the declaration to

[tt]Public MyClass As New Class1[/tt]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top