How to return value using addhandler event??

  • Thread starter Thread starter Kwok
  • Start date Start date
K

Kwok

Hi,

I have two objects, obj A for user input value, obj B for
get value from dataset.
I use obj B create obj A, how do I get parameters from obj
B when I add Handler and raiseEvent in obj A.

Thanks,
Kwok
 
I'm not sure what you mean, could you be a bit more specific? What exactly
are you trying to do? Could you give us any code/pseudocode examples?

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"


: Hi,
:
: I have two objects, obj A for user input value, obj B for
: get value from dataset.
: I use obj B create obj A, how do I get parameters from obj
: B when I add Handler and raiseEvent in obj A.
:
: Thanks,
: Kwok
 
Hi Kwok
Something like this I think

In B
Public Event KwokEvent()
Private b as integer
Public Property kwok(ByVal a As Integer) As Integer
Get
return = b
End Get
Set(ByVal Value As Integer)
b = value
End Set
End Property

In A
Private WithEvents KwokB As New B
dim X as integer = kwokB.a

I did not understand it clear where you did use the object, so can be totaly
wrong it is just a example to give you the keywords..

I hope this helps a little bit.

Cor
 
Hello,

Kwok said:
I have two objects, obj A for user input value, obj B for
get value from dataset.
I use obj B create obj A, how do I get parameters from obj
B when I add Handler and raiseEvent in obj A.

I don't really understand your question. Where do you add a handler?
Please provide more information.
 
Hi Tom, Herfried,

Return a value, like Cancel, or Handled, from a raised event.

Regards,
Fergus
 
Hi Herfried,

Keyboard events - Keep key - big debate? Handled = True

Form Close - Cancel - or not, maybe.

Kwok wants a return value from an event handler.
;-)

Regards,
Fergus
 
Fergus,
Was there something wrong with my little sample that I made special for Kwok
?
I take the same amount of time for those things as you I think.
Cor
 
Ah, that return value is passed back as a parameter of the event...

The event should be declared as a CancelEventHandler (I think)

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"


: Hi Herfried,
:
: Keyboard events - Keep key - big debate? Handled = True
:
: Form Close - Cancel - or not, maybe.
:
: Kwok wants a return value from an event handler.
: ;-)
:
: Regards,
: Fergus
:
:
 
Hi Cor,

What sample are you talking about?
There's not one in this thread.

I think too - CCCC rules ok.

Regards,
Fergus

* Caring Code Crafters Co-operative.
 
Cor,
I believe there was a problem with one of the news servers this morning, as
I know I replied to some posts and I have yet to see them. Maybe your sample
is hanging out with mine someplace in limbo...

Just a thought
Jay
 
I hate it when that happens.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"


: Cor,
: I believe there was a problem with one of the news servers this morning,
as
: I know I replied to some posts and I have yet to see them. Maybe your
sample
: is hanging out with mine someplace in limbo...
:
: Just a thought
: Jay
:
: : > Fergus,
: > Was there something wrong with my little sample that I made special for
: Kwok
: > ?
: > I take the same amount of time for those things as you I think.
: > Cor
: >
: >
:
:
 
Hi Kwok,
I don't know if you got it, things where not so good with newservers today I
see big differences.

The answer this morning about 8 o'clock GMT was.
Something like this I think

In B
Public Event KwokEvent()
Private b as integer
Public Property kwok(ByVal a As Integer) As Integer
Get
return = b
End Get
Set(ByVal Value As Integer)
b = value
End Set
End Property

In A
Private WithEvents KwokB As New B
dim X as integer = kwokB.a

I did not understand it clear where you did use the object, so can be
totaly
wrong it is just a example to give you the keywords..

I hope this helps a little bit.

Cor
 
I saw it too happen Jay, but I thougth it started at about 11 o'clock GMT
with those *.scr links (I asume it are virussen), it looks then if messages
where disapearing from the Microsoft servers. But maybe they never arrived.
 
Hello,

Fergus Cooney said:
Keyboard events - Keep key - big debate? Handled = True

Form Close - Cancel - or not, maybe.

Kwok wants a return value from an event handler.
;-)

I understand now...

;-)
 
Hello,

Jay B. Harlow said:
I believe there was a problem with one of the news
servers this morning, as I know I replied to some posts
and I have yet to see them.

Yep. My posts were "lost" too.

;-(
Maybe your sample is hanging out with mine someplace
in limbo...

Cor re-posted the sample.
 
Hello,

Kwok said:
I have two objects, obj A for user input value, obj B for
get value from dataset.
I use obj B create obj A, how do I get parameters from obj
B when I add Handler and raiseEvent in obj A.

Written from scratch, untested:

\\\
Public Class Foo
Public Event Bla( _
ByVal sender As Object, _
ByVal e As BlaEventArgs _
)

Public Sub RaiseTheEvent()
Dim e As New BlaEventArgs()
RaiseEvent Bla(Me, e)
MsgBox(e.Accept.ToString())
End Sub
End Class

Public Class BlaEventArgs
Inherits EventArgs

Private m_Accept As Boolean

Public Sub New()
m_Accept = True
End Sub

Public Property Accept() As Boolean
Get
Return m_Accept
End Get
Set(ByVal Value As Boolean)
m_Accept = Value
End Set
End Property
End Class
///

Usage:

\\\
Private WithEvents m_MyFoo As Foo
..
..
..
m_MyFoo = New Foo()
..
..
..
Public Sub m_MyFoo_Bla( _
ByVal sender As Object, _
ByVal e As BlaEventArgs _
) Handles m_MyFoo.Bla
If ... Then
e.Accept = False
End If
End Sub
///
 
Hi Herfried,

|| I understand now
|| ...

The ellipsis is important because ...


[see OT]
 
Back
Top