forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Morris

    #1

    forms

    If I click Button1, form2 show, then I click Button2 I get.



    "An unhandled exception of type 'System.NullRef erenceException ' occurred in
    WindowsApplicat ion13.exe


    Additional information: Object reference not set to an instance of an
    object."





    Why does ff = Nothing



    Code on Form 1



    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click

    Dim myfrom As New Form2

    myfrom.Show()

    End Sub



    Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button2.Click

    Dim ff As Form2

    Select Case ff.Visible

    Case True

    ff.Label1.Text = "This is form 2"

    End Select

    End Sub


  • AlexS

    #2
    Re: forms

    You did not instantiate form in Button2_Click. Check how you do declare form
    there.

    HTH
    Alex

    "Simon Morris" <nzavalanche@ho tmail.com> wrote in message
    news:uKhzWiiqDH A.1928@TK2MSFTN GP12.phx.gbl...[color=blue]
    > If I click Button1, form2 show, then I click Button2 I get.
    >
    >
    >
    > "An unhandled exception of type 'System.NullRef erenceException ' occurred[/color]
    in[color=blue]
    > WindowsApplicat ion13.exe
    >
    >
    > Additional information: Object reference not set to an instance of an
    > object."
    >
    >
    >
    >
    >
    > Why does ff = Nothing
    >
    >
    >
    > Code on Form 1
    >
    >
    >
    > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    > System.EventArg s) Handles Button1.Click
    >
    > Dim myfrom As New Form2
    >
    > myfrom.Show()
    >
    > End Sub
    >
    >
    >
    > Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
    > System.EventArg s) Handles Button2.Click
    >
    > Dim ff As Form2
    >
    > Select Case ff.Visible
    >
    > Case True
    >
    > ff.Label1.Text = "This is form 2"
    >
    > End Select
    >
    > End Sub
    >
    >[/color]


    Comment

    Working...