By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,165 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,165 IT Pros & Developers. It's quick & easy.

How to return value using addhandler event??

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
23 Replies


P: n/a
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"
"Kwok" <k_*****@hotmail.com> wrote in message
news:02****************************@phx.gbl...
: 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
Nov 20 '05 #2

P: n/a
Cor
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
Nov 20 '05 #3

P: n/a
Hello,

"Kwok" <k_*****@hotmail.com> schrieb:
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.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #4

P: n/a
Hi Tom, Herfried,

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

Regards,
Fergus
Nov 20 '05 #5

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
Return a value, like Cancel, or Handled, from a raised event.


???

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #6

P: n/a
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
Nov 20 '05 #7

P: n/a
Cor
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
Nov 20 '05 #8

P: n/a
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"
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
: 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
:
:
Nov 20 '05 #9

P: n/a
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.
Nov 20 '05 #10

P: n/a
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

"Cor" <no*@non.com> wrote in message
news:3f***********************@reader21.wxs.nl...
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

Nov 20 '05 #11

P: n/a
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"
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:#W**************@tk2msftngp13.phx.gbl...
: 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
:
: "Cor" <no*@non.com> wrote in message
: news:3f***********************@reader21.wxs.nl...
: > 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
: >
: >
:
:
Nov 20 '05 #12

P: n/a
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


Nov 20 '05 #13

P: n/a
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.


Nov 20 '05 #14

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
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...

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #15

P: n/a
Hello,

"Kwok" <k_*****@hotmail.com> schrieb:
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
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #16

P: n/a
Hello,

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> schrieb:
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.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #17

P: n/a
Hello,

"Tom Spink" <th**********@ntlworld.com> schrieb:
I hate it when that happens.


Did you run the screensavers posted in this group?

SCNR

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #18

P: n/a
Hi Herfried,

|| I understand now
|| ...

The ellipsis is important because ...
[see OT]


Nov 20 '05 #19

P: n/a
[continued]
....

Hey Presto!! - a Wonderful Sample.

Well done, H. :-)

Regards,
Fergus
Nov 20 '05 #20

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
Hey Presto!! - a Wonderful Sample.

Well done, H. :-)


I hope it compiles.

;-)

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #21

P: n/a
Hi Herfried,

The main thing is for Kwok to study it until he understands it. You've
done your bit. [I stood lazily on the side watching ;-)].

Regards,
Fergus
Nov 20 '05 #22

P: n/a
HI Cor,

Thanks for your help. Let me try it.

Kwok.
Nov 20 '05 #23

P: n/a
Hi Herfried.

thanks for your help

Kwok.
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> ¦b¶l¥ó
news:O7**************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
Hello,

"Kwok" <k_*****@hotmail.com> schrieb:
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
///

--
Herfried K. Wagner
MVP ?VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #24

This discussion thread is closed

Replies have been disabled for this discussion.