Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1349
  • Last Modified:

VB6 Compile Error: OBJECT DOES NOT SOURCE AUTOMATION EVENTS?


Greetings,

I am getting the following error message at VB6 compile time:

OBJECT DOES NOT SOURCE AUTOMATION EVENTS

With the following line of code highlighted as the culprit:

Private WithEvents frm As frmNewITProjectDlg

As for the form there is in fact a form called frmNewITProjectDlg in this project; any ideas as to why I would be getting this error and what a suitable fix or workaround might be? (see details below)

Thanks in Advance,

ADG13

------------------------------------------------------------------

According to the VB and OLE documentation my understanding is that the following should work:

In a VB6 class module of a project I have the following defined:

Option Explicit
'local variable(s) to hold property value(s)
Private mvarPhasesRequired As CProperties 'local copy
Private WithEvents frm As frmNewITProjectDlg

Private Sub Class_Initialize()
        Set mvarPhasesRequired = New CProperties
End Sub

Public Function Show() As Boolean

    Dim bCanceled As Boolean
    Set frm = New frmNewITProjectDlg
   
    With frm
        .ProjectName = Me.ProjectName
        .StartDate = Me.StartDate
        .CreateDate = Me.CreateDate
        Set .PhasesRequired = Me.PhasesRequired
       
        .Show vbModal
   
        Me.ProjectName = .ProjectName
        Me.StartDate = .StartDate
        Me.CreateDate = .CreateDate
        bCanceled = .Canceled
    End With
   
    Set frm = Nothing
    Show = Not bCanceled
   
End Function
0
adgarcia13
Asked:
adgarcia13
2 Solutions
 
Erick37Commented:
Change the declare to:
Private WithEvents frm As Form '<<-- change the type to Form

and to set it:
Set frm = New frmNewITProjectDlg
0
 
Arthur_WoodCommented:
what the error mesage is telling you is that while there are in fact events that are raised by a Form object, your code does NOT EXPLICITLY declare any Events for the form frmNewITProjectDlg.  That is, you do NOT have any lines, written by you, in the source code for frmNewITProjectDlg  that read

Public Event MyEvent(byVal MyArg as String)

.
.
.

Raise MyEvent("This event has just happended")


and since you do NOT have such code in the source code for frmNewITProjectDlg, declaring

Private WithEvents frm As frmNewITProjectDlg

is wrong as there are no User Events raised by the form.

AW


0
 
adgarcia13Author Commented:

Thanks Guys,

All information provided helped!

ADG13
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now