473,320 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to return value using addhandler event??

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
23 8241
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
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
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
Hi Tom, Herfried,

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

Regards,
Fergus
Nov 20 '05 #5
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
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
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
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
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
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
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
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
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
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
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
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
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
Hi Herfried,

|| I understand now
|| ...

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


Nov 20 '05 #19
[continued]
....

Hey Presto!! - a Wonderful Sample.

Well done, H. :-)

Regards,
Fergus
Nov 20 '05 #20
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
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
HI Cor,

Thanks for your help. Let me try it.

Kwok.
Nov 20 '05 #23
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nathan Sokalski | last post by:
I am using the AddHandler statement to add a CheckedChanged event handler to a series of RadioButtons that I create in a loop. However, the handler is not being called for a reason I cannot...
2
by: MLS | last post by:
The documentation on dynamic handlers comes across as abiguous. Perhaps somebody could help set me straight? I have a situation where I need to dynamically create several usercontrols of the...
10
by: Rick Palmer | last post by:
I have an app I'm working on that will allow a user to run one of 5 reports. The report names are in a combobox on my form. I have a sub defined for each report that has the exact same name as is...
1
by: sundog2000 | last post by:
I am writing my first VB.net program and I am struggling to figure out how to attach an event to a method, when the event is part of an interface that the class implements. I have declared a...
8
by: Radek Budaø | last post by:
Hi all, i have trouble with changing text value of textbox on runtime. I use this control to display process information about sending e-mail per smtp. I use external component >>Imports...
3
by: Henry Jones | last post by:
I am using VB.NET VS 2005 and I have a datagridview bound to a table. This table has rate information on bank loans. The fiels are ProductName, MinDeposit, Rate, and PreviousRate On the grid...
5
by: Slim | last post by:
i have a simple page, with one button button1. when click it creates a new button button 2 and adds a event handler to it. but when button 2 is clicked nothing happens, why? Partial Class...
15
by: Nathan Sokalski | last post by:
I have a section of my code that dynamically creates LinkButtons to allow the user to go to the page containing a question they have not answered. The code that creates the LinkButton is called, as...
1
by: Karl Rhodes | last post by:
I'm building a windows forms app in VB.net 2005 and would like to know if there is any way of adding a handler using a dynamic AddressOf value? The application will have a "Windows" menu item...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.