Results 1 to 3 of 3

Thread: Calling mdi form from login form

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2011
    Location
    Nairobi/Kenya
    Posts
    45

    Calling mdi form from login form

    I have a login form with the code below:
    Code:
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
    If txtuser.Text = "sky" And txtpass.Text = "123" Then
    Dim f As MDIParent = Me.MdiParent
    f.Show()
    Me.Close()
    'Me.Hide()
    'MdiParent.Show()
    Else
    MsgBox("Incorrect user info")
    txtuser.Focus()
    End If
    End Sub
    When i run this code and click OK, i get an error at f.show which says'Object reference not set to an instance of an object.'
    How do i go about it so that i can get a smooth login an access my MDI form?

  2. #2
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: Calling mdi form from login form

    You need to instantiate the MdiParent form...
    vb.net Code:
    1. Dim f As New MDIParent

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2011
    Location
    Nairobi/Kenya
    Posts
    45

    Re: Calling mdi form from login form

    The error still persists even with the change u have stated

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width