VB.Net - Load a form's properties and getting unhandled exception

Starting a new VB.Net project and crashed at first hurdle.

I am getting this error message >>>>

An unhandled exception of type 'System.NullReferenceException' occurred in Test.exe

What am I doing wrong?

And also how can stop the system putting in FormWindowState.Maximized. I just want = Maximised

How could I do this in a module rather than at form load?

***********
Private Sub frmMainMenu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Setup the frmMainMenu properties
frmMainMenu.ActiveForm.WindowState = FormWindowState.Maximized
frmMainMenu.ActiveForm.IsMdiContainer = True
frmMainMenu.ActiveForm.Text = "Main Menu"

End Sub
directredAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
>>And also how can stop the system putting in FormWindowState.Maximized. I just want = Maximised

Add this line to the top of the form module:
  Imports System.Windows.Forms.FormWindowState

Bob
0
 
kouroshparsaCommented:
You can set it maximized in the GDI of the form (easily)
or set it's state to maximized when the controls on the form are defined. Why in the module for God's sake?
0
 
kouroshparsaCommented:
To the author: If you want to ask questions and ignore some correct responds, this is not a forum for you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.