changing Load(form) to RaiseEvent
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: changing Load(form) to RaiseEvent

  1. #1
    Join Date
    Feb 2007
    Posts
    7

    changing Load(form) to RaiseEvent

    I'm converting an older VB program ( that I didn't write ) to the latest (VB 2005) and the UpgradeWizard has convered it all to the newest but it complains about this:

    Load(formname)

    'Public Event Load(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

    I'm fairly new to VB so I have no idea what to do, any ideas? I assume that if it was trivial then the wizard would have just changed it for me.

    Thanks
    Kevin

  2. #2
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: changing Load(form) to RaiseEvent

    and the UpgradeWizard has convered
    In general, using the UpgradeWizard for "real" "production" code is a BAD idea.

    There are enough architectural differences between VB6.0 and VB.Net that even if the program functions, it will be far from optimal on all fronts [performance, reliability, maintainability, etc].
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: changing Load(form) to RaiseEvent

    Well i assume Load is a Subprocedure.
    So here the name of sub conflicts with the load event in base class of Form.
    As a result the upgrade wizard changed its declaration as an event and wants it to be raised.
    Just change the sub-procedure's name and declaration to
    Code:
    Public Sub LoadForm(ByVal frmName as String)
    Last edited by aniskhan; April 9th, 2007 at 02:55 PM.

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: changing Load(form) to RaiseEvent

    And CPUWizard has already suggested, it is better to re-write the application. IMHO Upgrade Wizard nothing but a load of crap. It is there just for the sake of it. You will be better of re-writing the code rather than using the upgrade wizard.

    There is a toolkit that MS released sometime back. This helps you in doing an incremental upgrade and is easy to use. Have a look at Microsoft InteropForms Toolkit 1.0. This will help you in upgrading your application over the period of time to .NET and will let you keep the Forms from VB 6 too.

    Now coming back to your question. In .NET everything you create is a Class and in order to use it you need to create an object using the class. So when you add a Form to your project, you are basically adding a Class which contains the underlying code which is used to create the Form. At runtime you need to create an object using that Class. Now if you add a Form Form2 to your project and you want to show it, you need to do this
    Code:
    'create an object of type Form2
    Dim mySecondForm As New Form2
    'show the form
    mySecondForm.Show()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center