Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 9th, 2008, 12:48 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default Raise Events

Hi,
   I have created some control arrays using
Code:
Dim bButtons(4) As Button
Now assigning each buttons property is the easy part, but how do you assign it code?

I thought that custom making your on events would work, obviously being generic events that would be fed certain properties from the buttons that are clicked. So how would you create events to be raised?

If you can answer both do, but I really would like the second question's answer.

Thanks,


------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped! Soon changing as I have got so much better as a programmer!
__________________
Apocolypse2005, I'm a programmer - of sorts.
 
Old May 9th, 2008, 02:54 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I haven't tried this, but I would think that there would be one routine that has Handles bButtons.Click, and that some property of ByVal Sender As Object would provide the info you need to resolve where the event was raised from.
 
Old May 10th, 2008, 12:43 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you want to assign an event handler to a control, the general syntax is something like this:

  AddHandler myControl.Event, AddressOf myEventHandler

In your case, you need to loop thru all the items in the array and make that call for each one.

  ForEach aButton As Button In bButtons
    AddHandler aButton.OnClick, AddressOf myEventHandler
  Next

Then you need to provide the myEventHandler subroutine.

-Peter
compiledthoughts.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
raise event martijn1967 C# 1 May 30th, 2007 09:16 PM
Raise an Error in dynamic SQL with Link Server bashiiui SQL Server 2000 7 May 2nd, 2007 04:10 AM
How to raise event in user control webpart... tqit ASP.NET 2.0 Basics 1 September 13th, 2006 04:37 AM
Raise Event From Dynamic Controls netwizard_01 ASP.NET 1.0 and 1.1 Basics 1 August 3rd, 2006 06:50 AM
Raise Event for Dynamically Added DropDownList DolphinBay ASP.NET 1.0 and 1.1 Professional 3 December 6th, 2005 02:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.