Reputation: 241
I have a small application, written in visual basic.
I have 4 forms in the project, however when I try to access them using the My.Forms collection only 2 are displayed to select from? I also tried manually typing the name of one of the other forms that I need to access, but I get the error that the form is not a member of 'MyProjects.MyForms'
.
Do I need to add the other 2 forms to this collection? Shouldn't it happen automatically, as I didn't add the other 2?
Thanks
----EDIT----
I think the issue is due to me renaming the forms incorrectly. Is there a way to manually edit the My.Forms collection without having to create the forms from scratch again?
----EDIT----
The issue comes from me passing variables to the sub new method:
Public Sub New(id As Int32)
' This call is required by the designer.
InitializeComponent()
MsgBox(id)
' Add any initialization after the InitializeComponent() call.
End Sub
Am I declaring the variable wrong?
Thanks
Upvotes: 0
Views: 853
Reputation: 196
I'm sure I'm too late to help you out with your question, but for anyone else who needs help with this, I also determined that my form was removed from the My.Forms collection when I included a variable argument as part of my New() sub. I solved this problem by also including a New() sub that did not take any arguments (in other words, I overloaded the New() method). So in robbiecutting's example, the code would look like this:
Public Sub New()
' This call is required by the designer.
InitializeComponent()
End Sub
Public Sub New(id As Int32)
' This call is required by the designer.
InitializeComponent()
MsgBox(id)
' Add any initialization after the InitializeComponent() call.
End Sub
Upvotes: 1