V
VbaNew
Hi,
I found some very interesting programming stuff that was brought about
in the following:
Public Event SalaryChange(OldAmount As Single, NewAmount As Single,
Cancel As
Boolean)
Property Let Salary(Value As Single)
Dim Cancel As Boolean
RaiseEvent SalaryChange(pSalary, Value, Cancel)
If Cancel = True Then
MsgBox "Salary Change Overruled"
Else
pSalary = Value
End If
End Property
Now, this RaiseEvent statement is interesting in that, as opposed to a
usual procedure call, the event handler procedure called doesn't have
to exist. But the trouble is this:
1) We can't declare WithEvents in the same class or we get a compile
error!
2) The statement WithEvent *must* be in a class module.
The example above would be very useful indeed as a good class
programming example, if it could be finished. Using just the Salary
property, will one of you class gurus please be so kind as to finish
the job and modify/add the proper code in the class where the above
property comes from *and* write the regular module code and event
handler in the second class module so that it all hooks up nicely and
works? (not in the ThisWorkbook or sheet code module but in a regular
class module please).
Thanks.
I found some very interesting programming stuff that was brought about
in the following:
Public Event SalaryChange(OldAmount As Single, NewAmount As Single,
Cancel As
Boolean)
Property Let Salary(Value As Single)
Dim Cancel As Boolean
RaiseEvent SalaryChange(pSalary, Value, Cancel)
If Cancel = True Then
MsgBox "Salary Change Overruled"
Else
pSalary = Value
End If
End Property
Now, this RaiseEvent statement is interesting in that, as opposed to a
usual procedure call, the event handler procedure called doesn't have
to exist. But the trouble is this:
1) We can't declare WithEvents in the same class or we get a compile
error!
2) The statement WithEvent *must* be in a class module.
The example above would be very useful indeed as a good class
programming example, if it could be finished. Using just the Salary
property, will one of you class gurus please be so kind as to finish
the job and modify/add the proper code in the class where the above
property comes from *and* write the regular module code and event
handler in the second class module so that it all hooks up nicely and
works? (not in the ThisWorkbook or sheet code module but in a regular
class module please).
Thanks.