Need help creating an ActiveX Dll from a class

I need help creating an ActiveX Dll from the class posted below. Each time I try to compile the Dll, I get the following message error "No creatable public component detected." Also, after you create the DLL, could you create a sample project using the DLL in a standard exe?

Class:

Option Explicit

' The PictureBox we draw on.
Public picCanvas As PictureBox

' The rectangle's drawing attributes.
Public X0 As Single
Public Y0 As Single
Public Radius As Single
Public DrawWidth As Integer
Public ForeColor As OLE_COLOR
Public FillColor As OLE_COLOR
Public FillStyle As FillStyleConstants
Public DrawStyle As DrawStyleConstants

' Default property values.
Private Const m_def_X0 = 0
Private Const m_def_Y0 = 0
Private Const m_def_Radius = 80
Private Const m_def_DrawWidth = 1
Private Const m_def_ForeColor = vbBlack
Private Const m_def_FillColor = vbBlack
Private Const m_def_FillStyle = vbBlack
Private Const m_def_DrawStyle = vbSolid

' Draw on picCanvas.
Public Sub Draw()

   Form1.Picture1.ForeColor = ForeColor
   ' Set other drawing attributes.
   With fmyform(iCurrentProcId).picCanvas
       .FillStyle = FillStyle
       .FillColor = FillColor
       .DrawWidth = DrawWidth
       .DrawStyle = DrawStyle
   End With

   ' Draw the object.
   Form1.Picture1.Circle (X0, Y0), Radius, Form1.Picture1.ForeColor
End Sub

' Set default property values.
Private Sub SetDefaultProperties()
   X0 = m_def_Y0
   Y0 = m_def_X0
   Radius = m_def_Radius
   DrawWidth = m_def_DrawWidth
   ForeColor = m_def_ForeColor
   FillColor = m_def_FillColor
   FillStyle = m_def_FillStyle
   DrawStyle = m_def_DrawStyle
End Sub

' Set some defaults.
Private Sub Class_Initialize()
   SetDefaultProperties
End Sub
GmoneyAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
I have change this method of your class:

Public Sub Draw(ByRef fMyForm As Object)

  fMyForm.Picture1.ForeColor = ForeColor
  ' Set other drawing attributes.
  With fMyForm.picCanvas
      .FillStyle = FillStyle
      .FillColor = FillColor
      .DrawWidth = DrawWidth
      .DrawStyle = DrawStyle
  End With

  ' Draw the object.
  fMyForm.Picture1.Circle (X0, Y0), Radius, fMyForm.Picture1.ForeColor
End Sub

And I places this into a new standard EXE after having added a command button (command1), 2 picture box (picture1 and piccanvas) and after having set a reference to your DLL.

Option Explicit

Private Sub Command1_Click()
Dim x As Project1.Class1

    Set x = New Project1.Class1
    With x
        .X0 = 1000
        .Y0 = 1000
        .ForeColor = vbBlack
        .FillColor = vbRed
        .Radius = 500
        .Draw Me
    End With
End Sub
0
 
Richie_SimonettiIT OperationsCommented:
Try setting Instance property to 5-multiuse.
0
 
Richie_SimonettiIT OperationsCommented:
Where are those form and picture box, in a form?
If so, how class know about them. I cannot see any "connection"  between class module and form.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Richie_SimonettiIT OperationsCommented:
Besides, using public variables to simulate properties doesn't help you. It only gives you troubles.
In background, VB creates them anyway.
0
 
GmoneyAuthor Commented:
setting the Instance property to 5-multiuse helped some but I'm still receiving compile errors.
0
 
GmoneyAuthor Commented:
setting the Instance property to 5-multiuse helped some but I'm still receiving compile errors.
0
 
Éric MoreauSenior .Net ConsultantCommented:
the same error or a new one?
0
 
GmoneyAuthor Commented:
could someone copy the class, compile it into a dll, and email it to me in an example of using it?

emoreau, i'm getting different errors
0
 
GmoneyAuthor Commented:
i got the DLL compiled, now all i need is an example of how to call the DLL in a standard exe project.
0
 
Richie_SimonettiIT OperationsCommented:
You need to set a reference to that library in your standard exe and create a variable of its type (just like any other COM class):
i.e.

dim objMydll as MyActiveXDll

and from it, maybe you need to create a new one:
set objMydll = new MyActiveXDll.myclass

and you would be ready to use properties/methods from it.

That's a generic approach, you have to know the rest.Hope it helps
0
 
Éric MoreauSenior .Net ConsultantCommented:
You will need another public property into your class: fMyForm.
0
 
GmoneyAuthor Commented:
Richie could you please create an example project?
0
 
GmoneyAuthor Commented:
I still need a lot of help on this
0
 
GmoneyAuthor Commented:
How do I set reference to the DLL emoreau
0
 
Éric MoreauSenior .Net ConsultantCommented:
project -> references and then find your component into the displayed list.
0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
Richie_SimonettiIT OperationsCommented:
Could explain a little more where do you get the error. All is posting the same comments but...
0
 
GmoneyAuthor Commented:
emoreau mcdonald_g is my brother, we are working on the same problem
0
 
Richie_SimonettiIT OperationsCommented:
Did you work with active x dll before?
I mean, automating excel or word, or using FileSystem objects?
If so, you have to use the same approach with your own dll.
0
 
GmoneyAuthor Commented:
emoreau, what code do I put in the declarations part of the form?
0
 
GmoneyAuthor Commented:
emoreau, your all most there, just give me the complete code to implement the Dll in a standard exe.
0
 
Éric MoreauSenior .Net ConsultantCommented:
I already posted it in a previous post:

Option Explicit

Private Sub Command1_Click()
Dim x As Project1.Class1

   Set x = New Project1.Class1
   With x
       .X0 = 1000
       .Y0 = 1000
       .ForeColor = vbBlack
       .FillColor = vbRed
       .Radius = 500
       .Draw Me
   End With
End Sub


Are you missing something?
0
 
Richie_SimonettiIT OperationsCommented:
As i posted previously:
'general declarations section of form
dim objMydll as MyActiveXDll

'In sub form_load event
set objMydll = new MyActiveXDll.myclass
'start using methods/properties from here
end sub
0
 
GmoneyAuthor Commented:
Could someone email me sample project of the Dll and Exe at glynn.mcdonald@charter.net and I will post you the points. I followed the above directions and still got errors!
0
 
GmoneyAuthor Commented:
Someone please email me tonite, I need this for a project that I suppose to email my boss today.
0
 
Éric MoreauSenior .Net ConsultantCommented:
which errors?
0
 
GmoneyAuthor Commented:
Thanks a bunch
0
 
Éric MoreauSenior .Net ConsultantCommented:
will you convince your brother to accept the other question to me too?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.