Graphite2001 Posted September 30, 2003 Posted September 30, 2003 Hi All, I have been working with VB.Net for 2 weeks already. My task for now is to migrate a VB6 program to VB.Net. Right now I have encountered a probelm during migration. The scenerio is as follow: in VB6, i have an Active X user control "Monthly", i call it "Monthly_Day" (and yes, it is a calendar program). For this control, i have all the standard events (such as click, double click....) implemented as well as some user defined methods (for example, "Reset") i have a form, i call it "frm_Monthly". Inside this form, i have "drawn" 42 Monthly ActiveX controls. Logically, it's placed in a control array. There is a segment of code like the following: for i = 0 to 41 Monthly_Day(i).Reset next i I decided to leave the Monthly controls as is. (i.e. it stays as Active X ) After i finish the migration, I see that the widzard has created a new class, called "MonthlyArray", for me. (please see the attachment for reference) in the Windows Designer Generated Form section, i see the following statement: "Public WithEvents Monthly_Day As MonthlyArray" I'm able to compile and run the program without syntex error. However, when it runs to the loop mentioned above, it gives me an error message: (91) Object Reference not set to an instance of an object. Any information regarding to my problem will be greatly appreciated. THank you in advance. Ansonmonthlyarray.vb Quote
Administrators PlausiblyDamp Posted September 30, 2003 Administrators Posted September 30, 2003 Only had time to skim the code but, does it fail on starting the loop or when i is a particular value? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Graphite2001 Posted October 1, 2003 Author Posted October 1, 2003 it fails at the beginning of the loop. Quote
*Experts* Volte Posted October 1, 2003 *Experts* Posted October 1, 2003 I really don't recommend using the VB6 Migration Wizard at all. It generates terrible code that is hard to maintain and is very messy. It'll just create more work for you. I really recommend rewriting the project if possible. It will make things much easier to maintain and expand. Quote
Graphite2001 Posted October 1, 2003 Author Posted October 1, 2003 But what if i really have to this conversion? Sorry for all the trouble. Anson Quote
Administrators PlausiblyDamp Posted October 1, 2003 Administrators Posted October 1, 2003 Would probably save a lot of time in the long run to re-write. However if you step through the code when it reaches the line Monthly_Day(i).Reset what is the value for Monthly_Day in the watch window? what is the value for Monthly_Day(i) in the watch window? also does Monthly_Day(1) resturn a valid result? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Administrators PlausiblyDamp Posted October 1, 2003 Administrators Posted October 1, 2003 That's the problem. The array will need to be instantiated somewhere in the form. Good luck in figuring out where though, as VolteFace said earlier the Wizard tend to write out code that is very poor quality and fairly long winded and incomprehensible. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.