Events in class

Posted on 2003-03-16
Medium Priority
Last Modified: 2010-04-07
In my activeX dll project, I have the class as say class1.cls and a form say form1 with label1
from class1, i show the form from one function
i've declared one public event as 'gotClicked'
now what i want is when user clicks on label1 in form1 my gotClicked event [declared in class1] should be raised

Thank u

Question by:avya2k
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

happel earned 225 total points
ID: 8150061
In class1:
Public Event gotClicked()

Friend Sub RaiseAnEvent()
    RaiseEvent gotClicked
End Sub

Private Sub Class_Initialize()
    Set myClass = Me
End Sub

Public Sub Start()
    Dim mForm As Form1
    Set mForm = New Form1
    Call Load(mForm)
    Call mForm.Show(vbModal)
    Set mForm = Nothing
End Sub

In module1
Public myClass As Class1

In Form1
Private Sub Label1_Click()
    Call myClass.RaiseAnEvent
End Sub

Compile project (ActiveX DLL)

Start new 'Standard exe' project, rename project name to something else than 'project1'
Add reference to your new DLL

and add code

Private WithEvents myClass As Project1.Class1

Private Sub myClass_gotClicked()
    Call MsgBox("Clicked")
End Sub

Author Comment

ID: 8150820
That's very nice
i had tried the same way but failed due to minor mistake of declaration
but anyway ,that ehlped me a lot
Thanks a lot

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question