you are correct. To be honest, I am not sure why I said that originally (was 2 years ago). Although one thing to note is strings are actually immutable, not mutable.
Printable View
When adding an overloaded new constructor to a form it will never show up in the Project properties Startup form ComboBox. It should not matter but thought it prudent to mention. If you want it to show up then add a default new constructor along with the overloaded new constructor. For anyone who wants to try this out download the attachment, which has two, projects and load them. No need to build either project but instead look at the Startup ComboBox and note one form is missing in both. In the temp project note there is no form1 but it shows up in the Startup form ComboBox which happened when Form1 was removed then the form with an overloaded new constructor was added. Any ways I thought this was interesting as it happened to a fellow developer who asked me what was going on.
To me this is a non-issue unless you are not sure what the heck is going on.
There's a reason for that... When the application starts, it creates an instance of the form. As such, there isn't a way to pass parameters to the constructor of the form ... after all, how would it know what to send to the form? That's why you need to have a parameterless constructor of the form. So the IDE removes any form that doesn't have a parameterless constructor.
-tg
I'm still fairly new at VB (using VB .NET for the moment) and I have a question that I didn't see addressed in this thread.
I'm trying to pass a bunch of variables from one form to another. In other languages I have used, I've been able to build a structure (although I'm not sure how to do that in VB yet). For single variables I have been using the code that has been mentioned in this thread:
Private ReadOnly Property _PassMetFile1() As String
Get
Return firstmet.Text
End Get
End Property
and
Friend WriteOnly Property _ReceiveMetFile1() As String
Set(ByVal value As String)
metfile1 = value
End Set
End Property
I am not trying to pass about 25 fields from one form to another and I obviously don't want to go through those statements all 25 times.
Is there a way to build all 25 fields into one variable and pass it from one form to another?
Thanks
you can pass it as a List(Of String) ... you can use a custom class... or a structure... or an array even....
-tg
You can certainly create a class or structure and pass that. You would be changing the property to take a member of that class or structure type rather than a string, but it would otherwise work the same. If all the items you want to pass are strings, I would agree with TG that you should just pass a List(of String).
In any case, you may have just as much trouble populating a structure as you would passing 25 different values individually. Of course, there would be more code involved adding those 25 properties onto the form, but once you had done that, passing the values would be easier than filling a structure then passing the structure....unless your code is such that the structure can be filled for other reasons such that you get more benefit from having the structure than just to simplify passing it around.
Of course that also asks the question why so much needs to be passed over? Surely there's a better way ...
-tg
Thanks for the all the suggestions. I'm going to try to use the List(Of String) approach and see how that works. If it fails, I'll just pass everything over individually.
The reason that I need to pass a bunch of data is that I am creating an environment to run a program with a lot of variables. Generally the program will be run with default values and I won't need to the user to change them, but they need the ability to modify it if they want.
So, I made a seperate page to modify the default values. If they change them, then when they close that page, VB will use those new values instead of the default ones.