Results 1 to 4 of 4

Thread: Simple multiple form application

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2004
    Location
    San Diego
    Posts
    39

    Simple multiple form application

    I have an application with two forms, FrmLogin and FrmMain. When application opens up, FrmLogin pops up for authentication, once successful, FrmMain should open and FrmLogin should close. Looks like I can not close the FrmLogin! Any idea? Thanks.


    This is the code behind the Login Button. Unfortunately I can NOT close the FrmLogin once authentication is successful!

    VB Code:
    1. Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
    2.        
    3. If Me.TxtUsername.Text = "User” And Me.TxtPassword.Text = "password" Then
    4.  
    5.    Dim form2 As New FrmMain
    6.         form2.Show()
    7.  
    8. Else
    9.         Me.Close()
    10. End If
    11. End Sub
    Mike

  2. #2
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112
    courtesy of dynamic_sysop
    Attached Files Attached Files

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Simple multiple form application

    Originally posted by babakanoush
    I have an application with two forms, FrmLogin and FrmMain. When application opens up, FrmLogin pops up for authentication, once successful, FrmMain should open and FrmLogin should close. Looks like I can not close the FrmLogin! Any idea? Thanks.


    This is the code behind the Login Button. Unfortunately I can NOT close the FrmLogin once authentication is successful!

    VB Code:
    1. Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
    2.        
    3. If Me.TxtUsername.Text = "User” And Me.TxtPassword.Text = "password" Then
    4.  
    5.    Dim form2 As New FrmMain
    6.         form2.Show()
    7.  
    8. Else
    9.         Me.Close()
    10. End If
    11. End Sub
    The simple answer is set Sub Main of a Module as your startup object

    In the Module:

    VB Code:
    1. Public frmLogin as New FormLogin
    2. Public frm2 as New FrmMain
    3.  
    4. Public Sub Main()
    5.   frmLogin.ShowDialog()
    6.   frm2.ShowDialog()
    7. End Sub
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2004
    Location
    San Diego
    Posts
    39

    Thumbs up

    Thank you ayan... worked perfectly.
    Mike

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