Wrox Programmer Forums
|
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 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 December 26th, 2009, 05:25 AM
Registered User
 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Question Real beginner question

I am just starting to use VS 2008, Visual Basic. When I double click a button I get a procedure like:

Code:
     Private Sub mnuFilePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePrint.Click
           End Sub
Now if I want to make a call to this procedure what do I use for arguments?

I have tried
Code:
 Private Sub cmdPrintResults_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrintResults.Click
        mnuFilePrint_Click()
    End Sub
but I get a error messages like

"argument not specified for parameter 'e' of . . . "
and "argument not specified for parameter 'sender' of . . . "

Please help
 
Old December 26th, 2009, 05:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You typically don't call these event handlers directly as they are designed to handle a specific event (e.g. a Button's Click) called by the runtime or based on some user action. Instead, you can create a method that contains the code you typically have in the handler and call that method instead. E.g.:

Code:
 
Private Sub mnuFilePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePrint.Click
  PrintStuff()
End Sub
 
Private Sub cmdPrintResults_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrintResults.Click
  PrintStuff()
End Sub
 
Private Sub PrintStuff()
  ' Do here what you previously did in mnuFilePrint_Click
End Sub
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old December 26th, 2009, 01:19 PM
Registered User
 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thank You

That fixes my problem.

Thank You

Jerry





Similar Threads
Thread Thread Starter Forum Replies Last Post
a question from a beginner starnold BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 1 June 18th, 2009 10:36 AM
Question for the real tech lords. Warbird General .NET 2 November 10th, 2005 09:51 PM
Beginner Question dkr72 Excel VBA 1 January 18th, 2005 09:37 AM
beginner question saudyonline General .NET 2 September 21st, 2004 01:56 AM
PHP real question jimmychuck BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 14th, 2004 11:58 AM





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