"Object reference not set to an instance of an object?"

This question already has an answer here:

  • What is a NullReferenceException, and how do I fix it? 33 answers

  • You need to create a new instance of the form you want to display. You do this by creating a variable of form T and then showing it.

    If you don't create an instance of your form the MainForm.Show() code will be invoking Show() on an null reference.

    If PasswordTextBox.Text = pass Then
        Me.Hide()
        Dim theFormIWantToShow As New MainForm
        theFormIWantToShow.Show()
    End If
    
    链接地址: http://www.djcxy.com/p/28044.html

    上一篇: 将元素添加到null(空)List <T>属性

    下一篇: “你调用的对象是空的?”