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

Posted on 2005-05-12
Last Modified: 2010-04-17
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
Question by:directred
    LVL 2

    Expert Comment

    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?
    LVL 96

    Accepted Solution

    >>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

    LVL 2

    Expert Comment

    To the author: If you want to ask questions and ignore some correct responds, this is not a forum for you!

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now