There is no such concept as "open a form" in programming; you can only close a form :-)
You don't really pass the form name, which would not make any sense. Your
frmName
is a reference to an instance of
Form2
class (never ever use names like that; use refactoring engine to change each and every auto-generated names and avoid giving bad names yourself).
What you do makes little sense in principle. At least both your
frmName
and
InitForm
should be static (shared). Without it, you would have separate
frmName
for each instance of
Form2
. Apparently, you have little understanding of types, instances and instance members (vs static). You need to learn it.
It's possible that you are trying to combine
factory and
singleton patterns, or use just one of them. You are doing it wrong. Indeed, you can have a
factory method like yours, but it should either be a method of some "factory" class or a static method of the form class, which you could use instead of public/internal constructor (and then you should better make all constructors private). If you need a singleton feature, read this:
https://en.wikipedia.org/wiki/Singleton_pattern[
^].
I saw many bad singleton implementations. This is a right one:
http://csharpindepth.com/Articles/General/Singleton.aspx[
^].
See also:
https://en.wikipedia.org/wiki/Factory_%28object-oriented_programming%29#VB.NET[
^].
Now, for a side advice: I would recommend you to hold on UI development, as well as other as advanced or more advanced topics. First, get confident with classes, instances and OOP, using perhaps some simple console-only applications.
—SA