Click here to Skip to main content
15,936,247 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i'm a newbie, so in this problem i made a WPF Project with Visual Basic Code in Visual Studio 2019. And, i made 2 form. Like in the image.

1st Form's name was "LoginForm", the 2nd form's name was "MainForm"

Then, when in 1st Form, i wanted that when i pressed a button, it opens or shows up the 2nd form.

But, I can't find the 2nd form while typing "MainForm" in 1st Form. And the error says :

"Error BC30451 'MainForm' is not declared. It may be inaccessible due to its protection level."

Either the 2nd form was not considered as an object by the project or something. Do you guys have any ideas how to make it possible?

What I have tried:

1. Since the "MainForm" Was Classed as "Window1", i tried to type the code to define the "Window2" with :

Dim MainForm As New Window1

But it made another error :
"Error BC30454 Expression is not a method."

2. I tried to define "MainForm" as an object with :

Dim MainForm As Object

But i'm afraid the result will be an error because i'm trying to open up perhaps a null object.

Thank you so much for your future help.
Updated 24-Jan-21 21:16pm
Richard MacCutchan 23-Jan-21 4:49am    
Without seeing your code it is impossible to guess what is the problem.

1 solution

If the window's class name is MainForm, then you need to declare and create a variable of that type.
Dim window1 As New MainForm
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900