Results 1 to 6 of 6

Thread: Loading form ¿? (RESOLVED)

  1. #1

    Thread Starter
    Addicted Member Sanko's Avatar
    Join Date
    Mar 2000
    Location
    Argentina
    Posts
    128

    Question Loading form ¿? (RESOLVED)

    Hi i have 2 forms "form1" and "MdiPrincipal"

    In form1 i have a button when the user do a click the form1 must close and show the mdi

    Code:
    VB Code:
    1. Private Sub CmdAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdAceptar.Click
    2. Dim Mdi As New MdiPrincipal  
    3. Mdi.Show()
    4. 'Mdi.Dispose()
    5. Me.close()

    but when i click the button it opens the mdi and then automatically closes

    if i use
    VB Code:
    1. Mdi.ShowDialog(Me)
    it opens the Mdi but the form1 is already open

    if i use
    VB Code:
    1. Me.hide()
    the form1 is invisible but is in memory...

    I want to close the form1 and open the Mdi
    Last edited by Sanko; May 23rd, 2005 at 06:17 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Loading form ¿?

    You may want to use a Module Sub Main procedure as your startup object. Then in there you can run your
    form1 with .ShowDialog. When it gets disposed the next line of code in the sub main will execute. This would be your
    mdiprincipal.showdialog.

    VB Code:
    1. Option Explicit On
    2.  
    3. Module Module1
    4.     Public Sub Main()
    5.         Application.Run(New Form1)
    6.         Application.Run(New MdiPrincipal)
    7.     End Sub
    8. End Module
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: Loading form ¿?

    I generally have a construct where there is a perpetual loop in Sub Main. The loop calls a sub which holds a Select statement. For each case, I show a separate form. It looks something like this in Main:

    VB Code:
    1. theState=1
    2. do while thestate>0
    3.   Ladder
    4. loop

    Sub Ladder looks something like this:

    [Highlight=VB]

    Sub Ladder()
    select case theState

    case 1
    form1.showdialog
    case 2
    form2.showdialog
    end select
    end sub

    This means that each form only has to set the theState variable to the next form that should be shown, then it can close. Of course, in this example, the forms are all global instances, but you certainly could make them local to the select case.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Addicted Member Sanko's Avatar
    Join Date
    Mar 2000
    Location
    Argentina
    Posts
    128

    Re: Loading form ¿?

    Ok but i have a splash screen wich opens form1 and then i must open the MDI; the estructure looks like

    Show splash screen (validations, DB, etc) --> then closes the splash screen and opens ("form1") wich is a Login form if the user is acepted he must click a button which closes the login form and --> open the MDI

    Splash --> User Login --> MDI
    Last edited by Sanko; May 23rd, 2005 at 05:32 PM.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Loading form ¿?

    Since your splash form has the validation code in it you can probably organize it like so...
    VB Code:
    1. Option Explicit On
    2.  
    3. Module Module1
    4.     Public Sub Main()
    5.         Application.Run(New frmSplash)
    6.         Application.Run(New Form1)
    7.         Application.Run(New MdiPrincipal)
    8.     End Sub
    9. End Module
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Addicted Member Sanko's Avatar
    Join Date
    Mar 2000
    Location
    Argentina
    Posts
    128

    Resolved Re: Loading form ¿?

    Thanks

    RobDog888
    Shaggy Hiker

    for the tips now i got it working.







    Traspasing vb6 -> vb.net

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