PDA

Click to See Complete Forum and Search --> : I want to... . Plz Help Me...


rzhd
Jan 28th, 2001, 01:07 PM
I want to add a costum event in a built in object in VB
Like a form or another objects, how can i do this?

suppose i have an object in
a project in vb such as form. this form has
some events like: Load, MouseMove, Keypress and lablabla...,
now i want to add an event to these events.
how can i ?

THANX in advance

ps: i'm interested in to know farther about this subject, plz inform me if there are documents relared to this subject.

KrishnaSantosh
Feb 11th, 2001, 02:20 AM
Here Is It::

Event OnAdd(byval Result as long) 'The Arg Is Optional

Dim Res as long

Private Sub Form_Load()
AddNums 10,10
end sub

private sub AddNums(a as long,b as long)
Res=a+b
RaiseEvent OnAdd(Res)
end sub

private sub Form_OnAdd(byval Result as long)
msgbox Result
end sub
__________

If You Want To Know More(Like Properties ) EMail me.

Alfred
Feb 11th, 2001, 02:06 PM
I don't understand, in this code example the source and the destination of the message are the same. The form is sending a message to itself. Why should you do something like this?
If there is an external event (outside of the form) that must fire an event on the form you must create an extra class that can fire events. Look up the WithEvents keyword and the Event statement in the VB help files.

KrishnaSantosh
Feb 11th, 2001, 07:03 PM
You Can Have Events In The Class Modules Or The User Controls You Create. And Those Events Can Be Handled In Your Forms.

Alfred
Feb 12th, 2001, 02:03 AM
Yes, that was I mean. You need a event source (control or another class) and an event destination such as a VB form. No offence but if you create sample code as you did, it is must clearer if I create a completly working code sample that can be with cut and paste directly injto VB. Thanks.