Results 1 to 17 of 17

Thread: Open Splash Form - Close Splash & Load Form1

  1. #1

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Exclamation Open Splash Form - Close Splash & Load Form1

    Retyped:

    Splash screen appears, there is a button to continue. When button is pressed, Splash disappears and Form1 is loaded.

    I've used the Splash.hide() to hide the splash, but then I red somewhere that you should close the forms if they're not being used.

    So in this instance I have used:

    Code:
    Form1.Show()
            Me.Hide()
    Is this the correct sequence to closing the other form. If not can I use this command when the user has finished to close the main form which hopefully closes everything else where I used the .hide.

    Code:
    Application.Exit()
    Last edited by jokerfool; Feb 27th, 2013 at 01:42 PM.

  2. #2
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Re: Open new form close current form

    When opening a form from another form and closing the called form

    lets say form1 and form2
    call form2 from form1 , & once the form2 is loaded close the form1 ?

    Code:
    Private Sub Somebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    '' open the form2
    
            Dim f As New Form2
            f.Show()
    
        End Sub
    ''once the form2 is loaded , close the form 1 now

    Code:
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Form1.Close()
    End sub
    '' now i am disposing off the form1 object from memory
    Code:
    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
            Me.Dispose()
        End Sub
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  3. #3

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: Open new form close current form

    Okay so now you've confused me.

    What exactly do I place between the subs?

    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
        End Sub

  4. #4
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Re: Open new form close current form

    i am confused now, in fact what you want to do on click of button1 ? you put that code with in the sub
    that's what the code code does here
    Code:
    Private Sub Somebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    '' open the form2
    
            Dim f As New Form2
            f.Show()
    
        End Sub
    and so on read further a
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  5. #5

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: Open new form close current form

    Nope that doesnt work, original form still there. If I add the other code says error.

  6. #6

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: Open new form close current form

    Wait, did I do something wrong here?

    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim f As New Form1
            f.Show()
            Form9.Close()
            Me.Dispose()
        End Sub

  7. #7
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Re: Open new form close current form

    you need to go through all the codes & in which event it is being triggered
    ( concentrate on the events of which form happening what , code is very easy and straight forward )

    what you did here is
    ''
    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim f As New Form1
            f.Show() ' you have sown the form1 here Presumably from Form9 
                        ' fine form1 is opened now you are in form1 
                        ' form9 is still open Right ? 
                         ' then when it is going to close , i think that's what is your worry
            Form9.Close() ' this line supposed to close the form9 , but what happen , you better set a break point here & run the app
            Me.Dispose() ' here who is the me , form1 or form9
    
    that's why your last 2 lines of code is being triggered at the form load event of form9 
    means form9 takes birth & once it takes the birth it closes it's  mother  , & once the mother closes ( see form closed event )
    it disposes off completely
    
    
        End Sub
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  8. #8

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: Open new form close current form

    Okay need some help still, not quite got it.

    Does
    Code:
    Dim f As New Form1
    mean get ready to open Form 1?

    And this means
    Code:
    Form9.Close()
    once the button is pressed close the current form which is Form 9 then Dispose of it and run Form 1? I think I am still lost somewhere.

  9. #9
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Open new form close current form

    Quote Originally Posted by jokerfool View Post
    Wait, did I do something wrong here?

    Code:
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim f As New Form1
            f.Show()
            Form9.Close()
            Me.Dispose()
        End Sub
    That's not remotely the code he posted for you...

    You are trying to do everything in one event, he showed you how to do it with three events...
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  10. #10

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: Open new form close current form

    So are you saying in .NET you cant do everything in one event I have to do it in 3?

  11. #11

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: Open new form close current form

    Blank Form with 1 button

    Code:
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class Form9
        Inherits System.Windows.Forms.Form
    
        'Form overrides dispose to clean up the component list.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.Button1 = New System.Windows.Forms.Button()
            Me.SuspendLayout()
            '
            'Button1
            '
            Me.Button1.Location = New System.Drawing.Point(144, 134)
            Me.Button1.Name = "Button1"
            Me.Button1.Size = New System.Drawing.Size(127, 82)
            Me.Button1.TabIndex = 0
            Me.Button1.Text = "Button1"
            Me.Button1.UseVisualStyleBackColor = True
            '
            'Form9
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(682, 507)
            Me.Controls.Add(Me.Button1)
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
            Me.MaximizeBox = False
            Me.MinimizeBox = False
            Me.Name = "Form9"
            Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
            Me.Text = "Form9"
            Me.ResumeLayout(False)
    
        End Sub
        Friend WithEvents Button1 As System.Windows.Forms.Button
    
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim f As New Form1
            f.Show()
        End Sub
    
        Private Sub Form9_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
            Me.Dispose()
        End Sub
    
        Private Sub Form9_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Form9.Close()
        End Sub
    End Class
    It surely cant be this hard, I know people dont like giving the answers away and let the user try and try and try and get error after error, dont tell me the answer just explain if you can what I have done wrong im still all new at this, thanks for helping.

  12. #12
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Open new form close current form

    Quote Originally Posted by jokerfool View Post
    So are you saying in .NET you cant do everything in one event I have to do it in 3?
    That should be apparent by the fact it isn't working. Events fire based on different actions. Put things in their proper place. The couple extra lines of code aren't going to hurt you to make sure things go into the right events.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  13. #13

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: Open new form close current form

    Why create a software application that requires 3 events yet in vb6 I could do it in one event, thats what confuses me, all this seems so complicated just to open a splash, close it and display a form.

  14. #14
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Open new form close current form

    Quote Originally Posted by jokerfool View Post
    Why create a software application that requires 3 events yet in vb6 I could do it in one event, thats what confuses me, all this seems so complicated just to open a splash, close it and display a form.
    Stop trying to compare it to VB6 and you will sleep much better at night. Just because you could get away with something doesn't mean you should. That can lead to all sorts of issues down the road when things get more complicated.

    Put it this way. Every play pool? Do you still play slop like you did when you were 12, or do you call your shots now?
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  15. #15
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Open new form close current form

    Quote Originally Posted by jokerfool View Post
    Why create a software application that requires 3 events yet in vb6 I could do it in one event, thats what confuses me, all this seems so complicated just to open a splash, close it and display a form.
    It isn't. But this wasn't the question you asked. You wanted to know how to open a new form from a button and close the form on which the button was clicked. At no point did you suggest that this was a splash scenario. We can't answer questions you don't ask. So describe exactly the sequence of events, including all interaction such as clicks, that you're proposing and we might be able to get there!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  16. #16

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: Open new form close current form

    I've edited the first post.

  17. #17
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Open Splash Form - Close Splash & Load Form1

    Did you create the splash screen as shown here

    http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx

    To set the time it shows

    http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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