I wonder if you can open a VB.NET
form1 from C#
form1
like VB.NET
Form1.Show();
inside the button function of the C#
code. I just thought of this will trying learn various code in them, can someone help to verify if this is possible???

- 357
- 4
- 14

- 13
- 2
-
1Well you'd create an instance of the form then call `Show` on it, yes. – Jon Skeet Oct 14 '21 at 07:46
-
2It looks like you might be used to using the "default instance" from the VB side. As far as I know, that's purely a VB construction and would not be available from C#. On the C# side, you would need something like `var form = new Form1(); form.Show();`. – Craig Oct 14 '21 at 13:03
1 Answers
The answer is Yes, but you can't have C# and VB.net in a single project. So create a solution containing two projects, one in C# the other in Vb.Net and you can open the vb.Net project form in C# as you suggest.
There is one major consideration though - that's dependencies. For this to work, the vb.net project is a dependency of the c# project, so the C# project sees all the VB.Net project but not the other way around.
It is possible to configure the solution to make both projects reference eachother - here's a post about it. Reference in two projects
However that's complicated and so I'd suggest having a third project (or fourth if needed) that contains any code you want to have common to both the VB and C# projects as a dependency to them both.

- 2,262
- 2
- 13
- 17
-
oh, wow, I'll try to make it, very interesting for me, THANKS ALOT MAN – zerbe Rous Oct 14 '21 at 23:01
-