Form Loading in VB .net [modified]
-
Not sure what I did here, I am new to .net and have been thrown into upgrading an app. I have a main form and a sub form and the upgrade wizard seemed to do a upgrade to teh form load and called "frmChamber.definstance.show(). This was all working very well as I moved on to other items. (working on controls and menus for that form) I think I got all that working but now I have trouble loading the form. All I changed the sub form is adding context menus and some text boxes to labels and such) one of the first things the form does is open a comm port mcomm1.portopen = true , now I get an error "object reference set to an instance of an object" when I try to do that. I get the same error when I do dim frmChamber as new frmChamber frmChamber.show() I get the same error on the dim statement (before the show event) what is the proper way to load a form? What am I doing wrong, this was working before.... the message is thrown on the line Me.components = New System.ComponentModel.Container in the InitializeComponent() section. I load a different form before this one and it works fine... no-e
modified on Tuesday, June 16, 2009 11:16 AM
-
Not sure what I did here, I am new to .net and have been thrown into upgrading an app. I have a main form and a sub form and the upgrade wizard seemed to do a upgrade to teh form load and called "frmChamber.definstance.show(). This was all working very well as I moved on to other items. (working on controls and menus for that form) I think I got all that working but now I have trouble loading the form. All I changed the sub form is adding context menus and some text boxes to labels and such) one of the first things the form does is open a comm port mcomm1.portopen = true , now I get an error "object reference set to an instance of an object" when I try to do that. I get the same error when I do dim frmChamber as new frmChamber frmChamber.show() I get the same error on the dim statement (before the show event) what is the proper way to load a form? What am I doing wrong, this was working before.... the message is thrown on the line Me.components = New System.ComponentModel.Container in the InitializeComponent() section. I load a different form before this one and it works fine... no-e
modified on Tuesday, June 16, 2009 11:16 AM
-
No-e wrote:
"object reference set to an instance of an object"
Hint: Something is nothing.
जय हिंद
modified on Tuesday, June 16, 2009 11:50 AM
Nothing
in VB :) -
Nothing
in VB :) -
No-e wrote:
"object reference set to an instance of an object"
Hint: Something is nothing.
जय हिंद
modified on Tuesday, June 16, 2009 11:50 AM
sorry, typo, error is "Object Reference not set to an instance of an object" the error appears in the InitializeComponent Me.components = New System.ComponentModel.Container Is it possible a control I added to teh form could cause this? (I added a context menu and a label)
-
Not sure what I did here, I am new to .net and have been thrown into upgrading an app. I have a main form and a sub form and the upgrade wizard seemed to do a upgrade to teh form load and called "frmChamber.definstance.show(). This was all working very well as I moved on to other items. (working on controls and menus for that form) I think I got all that working but now I have trouble loading the form. All I changed the sub form is adding context menus and some text boxes to labels and such) one of the first things the form does is open a comm port mcomm1.portopen = true , now I get an error "object reference set to an instance of an object" when I try to do that. I get the same error when I do dim frmChamber as new frmChamber frmChamber.show() I get the same error on the dim statement (before the show event) what is the proper way to load a form? What am I doing wrong, this was working before.... the message is thrown on the line Me.components = New System.ComponentModel.Container in the InitializeComponent() section. I load a different form before this one and it works fine... no-e
modified on Tuesday, June 16, 2009 11:16 AM
Apart from anything that others might mention, and assuming it is not another typo this line:
dim frmChamber as new frmChamber <======== problem line
frmChamber.show()is trying to create a member with the same name as the class. I'm essentially a C# chap but I think you might do better with this:
dim _frmChamber as new frmChamber <======== Note underscore added, ditto on line below
_frmChamber.show()[Edit] Incidentally I hate the use of underscores in member names, but I see this in a lot of the VB.Net posts, so I used it here. If there are better VB naming conventions, use one of those. :) [/Edit]
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Apart from anything that others might mention, and assuming it is not another typo this line:
dim frmChamber as new frmChamber <======== problem line
frmChamber.show()is trying to create a member with the same name as the class. I'm essentially a C# chap but I think you might do better with this:
dim _frmChamber as new frmChamber <======== Note underscore added, ditto on line below
_frmChamber.show()[Edit] Incidentally I hate the use of underscores in member names, but I see this in a lot of the VB.Net posts, so I used it here. If there are better VB naming conventions, use one of those. :) [/Edit]
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Thanks, I think I found the problem. As part of my learning curve I added control to a form (a label). I then tried to rename it and got an error as it had apparently figured out that I had actually declared it in my code. I thought I then deleted it but after chasing this down for a bit I found that on the design view that the control re-appeared under a different name. I just deleted it and it works again. bug in Visual studio? No-e
-
Thanks, I think I found the problem. As part of my learning curve I added control to a form (a label). I then tried to rename it and got an error as it had apparently figured out that I had actually declared it in my code. I thought I then deleted it but after chasing this down for a bit I found that on the design view that the control re-appeared under a different name. I just deleted it and it works again. bug in Visual studio? No-e
Don't know about a specific bug, but the Designer can get screwed from time to time, by things like that. Anyway, good luck! :)
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”