PC Review


Reply
Thread Tools Rate Thread

Can I declare an event in Excel 97?

 
 
geoff_ness
Guest
Posts: n/a
 
      3rd Jun 2009
I have defined a class to handle the user interface layer between a
form and a worksheet. The below is what is contained in the class
module:

Public Event GetJudicialOfficers(ByRef vsJOList As Variant)
Public Event GetCourtRooms(ByRef vsCourtrooms As Variant)

' Pick up change in Judicial Officer type from form
Public Sub JOTypeSelected(ByVal sType As String)
Dim vsOfficers As Variant

' Get the list of JOs from the return
vsOfficers = vUpdateJOList(sType)

' Pass the list back to the form
RaiseEvent GetJudicialOfficers(vsOfficers)

End Sub

Public Sub CourtSelected(ByVal sCourt As String)
Dim vsRooms As Variant

' Get the list of courtrooms based on selected court
vsRooms = vUpdateCourtList(sCourt)

' Pass the list back to the form
RaiseEvent GetCourtRooms(vsRooms)

End Sub

This compiles fine in both Excel 2003 and 2007. However in Excel 97
all the lines with either 'Public Event' or 'RaiseEvent' generate a
compile error (Identifier expected). Clearly this version of VBA does
not recognise these identifiers, I'm assuming along the same lines as
with Enum. Can anyone confirm that this is the case?

Cheers
Geoff
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      3rd Jun 2009
Event and RaiseEvent are not supported in Excel 97.

However, whilst it might not help you for your current needs, even in Excel
97 you can use WithEvents to trap and receive a custom event that you have
raised in another app, eg in a VB6 dll.

From what you describe there should be various alternative approaches to do
similar. Why not reference your class object directly in the form.

Regards,
Peter T

"geoff_ness" <(E-Mail Removed)> wrote in message
news:977dd03a-f072-4638-b93e-(E-Mail Removed)...
>I have defined a class to handle the user interface layer between a
> form and a worksheet. The below is what is contained in the class
> module:
>
> Public Event GetJudicialOfficers(ByRef vsJOList As Variant)
> Public Event GetCourtRooms(ByRef vsCourtrooms As Variant)
>
> ' Pick up change in Judicial Officer type from form
> Public Sub JOTypeSelected(ByVal sType As String)
> Dim vsOfficers As Variant
>
> ' Get the list of JOs from the return
> vsOfficers = vUpdateJOList(sType)
>
> ' Pass the list back to the form
> RaiseEvent GetJudicialOfficers(vsOfficers)
>
> End Sub
>
> Public Sub CourtSelected(ByVal sCourt As String)
> Dim vsRooms As Variant
>
> ' Get the list of courtrooms based on selected court
> vsRooms = vUpdateCourtList(sCourt)
>
> ' Pass the list back to the form
> RaiseEvent GetCourtRooms(vsRooms)
>
> End Sub
>
> This compiles fine in both Excel 2003 and 2007. However in Excel 97
> all the lines with either 'Public Event' or 'RaiseEvent' generate a
> compile error (Identifier expected). Clearly this version of VBA does
> not recognise these identifiers, I'm assuming along the same lines as
> with Enum. Can anyone confirm that this is the case?
>
> Cheers
> Geoff



 
Reply With Quote
 
geoff_ness
Guest
Posts: n/a
 
      3rd Jun 2009
Thanks Peter, I thought that might be the case. I'll most likely ditch
the class altogether as it basically serves no purpose other than to
raise those events for the form to trap. I think the form can just
call the functions to populate those lists directly, it's just never
as nice to do it that way. The VB6 idea is a good one, unfortunately
I'm restricted to VBA with this project.

Thanks
Geoff

On Jun 3, 8:54*pm, "Peter T" <peter_t@discussions> wrote:
> Event and RaiseEvent are not supported in Excel 97.
>
> However, whilst it might not help you for your current needs, even in Excel
> 97 you can use WithEvents to trap and receive a custom event that you have
> raised in another app, eg in a VB6 dll.
>
> From what you describe there should be various alternative approaches to do
> similar. Why not reference your class object directly in the form.
>
> Regards,
> Peter T
>
> "geoff_ness" <geoffne...@gmail.com> wrote in message
>
> news:977dd03a-f072-4638-b93e-(E-Mail Removed)...
>
> >I have defined a class to handle the user interface layer between a
> > form and a worksheet. The below is what is contained in the class
> > module:

>
> > Public Event GetJudicialOfficers(ByRef vsJOList As Variant)
> > Public Event GetCourtRooms(ByRef vsCourtrooms As Variant)

>
> > ' Pick up change in Judicial Officer type from form
> > Public Sub JOTypeSelected(ByVal sType As String)
> > Dim vsOfficers As Variant

>
> > ' Get the list of JOs from the return
> > vsOfficers = vUpdateJOList(sType)

>
> > ' Pass the list back to the form
> > RaiseEvent GetJudicialOfficers(vsOfficers)

>
> > End Sub

>
> > Public Sub CourtSelected(ByVal sCourt As String)
> > Dim vsRooms As Variant

>
> > ' Get the list of courtrooms based on selected court
> > vsRooms = vUpdateCourtList(sCourt)

>
> > ' Pass the list back to the form
> > RaiseEvent GetCourtRooms(vsRooms)

>
> > End Sub

>
> > This compiles fine in both Excel 2003 and 2007. However in Excel 97
> > all the lines with either 'Public Event' or 'RaiseEvent' generate a
> > compile error (Identifier expected). Clearly this version of VBA does
> > not recognise these identifiers, I'm assuming along the same lines as
> > with Enum. Can anyone confirm that this is the case?

>
> > Cheers
> > Geoff


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to declare custom event in interface rodchar Microsoft C# .NET 2 30th Jul 2008 04:37 PM
Declare Function for global use then call on change event gwoodby@gmail.com Microsoft Excel Programming 1 16th Nov 2007 04:26 PM
Re: I m VB 6.0 Programmer. How do i declare/raise event with VB.NET. Vijay Bhatt \(VB\) Microsoft VB .NET 6 8th Sep 2004 03:16 PM
Declare an Event within an Interface Derrick Microsoft C# .NET 2 8th Jul 2004 03:05 PM
How do I declare an Excel add-in in Access? Hennie Microsoft Access Form Coding 7 17th Jun 2004 12:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:45 PM.