473,403 Members | 2,071 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,403 software developers and data experts.

Button event

Art
Hi,

I've got a main module that instantiates a form and then does form.showdialog.

The form has a button. I want the main module to respond to a click event
from the button. I'm having trouble.

I tried declaring the button with events in the module and added a handler,
but it didn't trigger. I then made my own event in the form, raised in
inside the button's click event and put a handler for that in the module.
Again no good.

Obviously I'm missing something. Can anyone help me do this?

Art

Jun 21 '06 #1
3 954
Post relevant code please

Jun 21 '06 #2
"Art" <Ar*@discussions.microsoft.com> schrieb:
I've got a main module that instantiates a form and then does
form.showdialog.

The form has a button. I want the main module to respond to a click event
from the button. I'm having trouble.

I tried declaring the button with events in the module and added a
handler,
but it didn't trigger. I then made my own event in the form, raised in
inside the button's click event and put a handler for that in the module.
Again no good.


Private WithEvents Button1 As Button
....
Dim f As New Form1()
Button1 = f.Button1
f.Show()
....
Private Sub Button1_Click( _
ByVal sender As Object, ByVal e As EventArgs _
) Handles Button1.Click
MsgBox("Hello world!")
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 21 '06 #3
Art
Herfried,

Thank you very much -- it worked very well. I think I got confused as to
which object I needed to declare with events.

Thanks again,

Art

"Herfried K. Wagner [MVP]" wrote:
"Art" <Ar*@discussions.microsoft.com> schrieb:
I've got a main module that instantiates a form and then does
form.showdialog.

The form has a button. I want the main module to respond to a click event
from the button. I'm having trouble.

I tried declaring the button with events in the module and added a
handler,
but it didn't trigger. I then made my own event in the form, raised in
inside the button's click event and put a handler for that in the module.
Again no good.


Private WithEvents Button1 As Button
....
Dim f As New Form1()
Button1 = f.Button1
f.Show()
....
Private Sub Button1_Click( _
ByVal sender As Object, ByVal e As EventArgs _
) Handles Button1.Click
MsgBox("Hello world!")
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Girish | last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as <input type="image">. I need to be able to eble the ENTER button for both buttons. Yes, I know that for the input type...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
8
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.