-
April 9th, 2007, 12:58 PM
#1
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
-
April 9th, 2007, 01:30 PM
#2
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,2010
In theory, there is no difference between theory and practice; 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
-
April 9th, 2007, 01:37 PM
#3
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 01:55 PM.
-
April 10th, 2007, 12:02 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
On-Demand Webinars (sponsored)
|