none
Help With If statement. RRS feed

  • Question

  • Hello, I need help with my if statement, I want it so that after the Picture Box disappears, the form closed and the other one opens.

    Here is the PictureBox Code:

        Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
            PictureBox1.Image = My.Resources.logo
            Dim t As Task = Task.Run(Sub()
                            Threading.Thread.Sleep(5000)
                            Me.Invoke(Sub()
                            PictureBox1.Visible = False
                     End Sub)
            End Sub)
        End Sub

    Where do I put my If statement:

    If(PictureBox1.Visible = false) Then
    Me.Close()
    OtherForm.Show()
    End If

    Saturday, June 3, 2017 11:19 AM

Answers

All replies

  • It is easily to do by removing the application framework and to let the first and second form run after each other. 

    But why are you doing this so difficult with 2 forms. 

    2 simple panels and you have the same effect. 


    Success
    Cor

    Saturday, June 3, 2017 11:42 AM
  •  It appears that you are using a Form as a SplashScreen to show your logo image before the application opens.  If that is what you are doing,  then use a SplashScreen as Tom suggested in your last question about showing the image for 5 seconds.

     Add a SplashScreen to your project by going to the Menu and selecting (Project / Add New Item).  From there you can select a SplashScreen as shown in the image below.   Then delete the existing controls on it.  Remove the default code in the Load event of it too.  Then set its BackGroundImage to your logo image....

     

      Now,  go to the menu again and select (Project / YourProjectName Properties...).  When it opens,  on the Application tab,  select your SplashScreen`s name as the SplashScreen as shown below.

     

     Now this SplashScreen will be shown when your application is started  (test it).  If you want to adjust the length of time that it is shown for before your main application form is shown then follow the below steps...

     On the application's properties tab,  just to the right of the "Splash Screen" combobox you set in the last step,  press the (View Application Events) button.  That will open a new tab where you can use the OnInitialize event to set the minimum splash screen time as shown below.

    Imports System.Collections.ObjectModel
    
    Namespace My
        ' The following events are available for MyApplication:
        ' Startup: Raised when the application starts, before the startup form is created.
        ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
        ' UnhandledException: Raised if the application encounters an unhandled exception.
        ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
        ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
        Partial Friend Class MyApplication
    
            Protected Overrides Function OnInitialize(commandLineArgs As ReadOnlyCollection(Of String)) As Boolean
                Me.MinimumSplashScreenDisplayTime = 5000 '1000 milliseconds is equal to 1 second.  So, 5000 milliseconds would be 5 seconds
                Return MyBase.OnInitialize(commandLineArgs)
            End Function
        End Class
    End Namespace
    
     


    If you say it can`t be done then i`ll try it

    • Proposed as answer by dbasnett Saturday, June 3, 2017 12:18 PM
    Saturday, June 3, 2017 12:06 PM
  • I don't want't the splash screen because this is gonna be a full screen application
    Saturday, June 3, 2017 3:16 PM
  • I don't want't the splash screen because this is gonna be a full screen application

     Soooo... what does a full screen application have to do with it?  A SplashScreen is a SplashScreen and will be shown no matter what size you make the Form(s) or the SplashScreen.

     Perhaps you have just not explained enough for us to understand what you want to accomplish and how this form is to interact with your main form.


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Saturday, June 3, 2017 3:32 PM
    Saturday, June 3, 2017 3:29 PM
  • I don't want't the splash screen because this is gonna be a full screen application

    You can use any form for the splash screen form. It does not have to be the splashscreen control. Just make a new form in the project as choose it as the splash screen where Razerz shows. Then in the form load etc set the formup however you want.

    Saturday, June 3, 2017 3:31 PM
  • I did it with a Timer and it works perfectly fine.
    Saturday, June 3, 2017 5:45 PM
  • I did it with a Timer and it works perfectly fine.


    Success
    Cor

    Saturday, June 3, 2017 7:23 PM