load form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yxq

    load form

    Hi,
    My form will execute lots of codes when loaded, result in the form shown
    slowly, how to execute the codes after the form already shown?

    Thanks



  • Cor

    #2
    Re: load form

    Hi Yxq

    I think that has no benefit,

    Maybe this splash form is something for you?

    Cor
    \\\form1
    Private frm As New Form2
    Private Sub Form1_Load(ByVa l sender _
    As Object, ByVal e As System.EventArg s) _
    Handles MyBase.Load
    frm.Show()
    End Sub

    ///
    \\\form2

    Private WithEvents timer1 As New Windows.Forms.T imer
    Private Sub Form2_Load(ByVa l sender As Object, _
    ByVal e As System.EventArg s) Handles MyBase.Load
    Label1.Text = "I am busy"
    Me.ForeColor = Color.White
    timer1.Enabled = True
    timer1.Interval = 125
    Me.BackColor = Color.Cornflowe rBlue
    Me.Opacity = 1
    Me.TopMost = True
    Me.Text = "Splash"
    End Sub
    Private Sub Timer1_Tick(ByV al sender As System.Object, _
    ByVal e As System.EventArg s) Handles timer1.Tick
    Me.Opacity -= 0.01
    If Me.Opacity = 0 Then
    timer1.Enabled = False
    Me.Close()
    End If
    End Sub
    ///


    Comment

    • Cor

      #3
      Re: load form

      Hi Yxq

      I think that has no benefit,

      Maybe this splash form is something for you?

      Cor
      \\\form1
      Private frm As New Form2
      Private Sub Form1_Load(ByVa l sender _
      As Object, ByVal e As System.EventArg s) _
      Handles MyBase.Load
      frm.Show()
      End Sub

      ///
      \\\form2

      Private WithEvents timer1 As New Windows.Forms.T imer
      Private Sub Form2_Load(ByVa l sender As Object, _
      ByVal e As System.EventArg s) Handles MyBase.Load
      Label1.Text = "I am busy"
      Me.ForeColor = Color.White
      timer1.Enabled = True
      timer1.Interval = 125
      Me.BackColor = Color.Cornflowe rBlue
      Me.Opacity = 1
      Me.TopMost = True
      Me.Text = "Splash"
      End Sub
      Private Sub Timer1_Tick(ByV al sender As System.Object, _
      ByVal e As System.EventArg s) Handles timer1.Tick
      Me.Opacity -= 0.01
      If Me.Opacity = 0 Then
      timer1.Enabled = False
      Me.Close()
      End If
      End Sub
      ///


      Comment

      • John

        #4
        RE: load form

        I don't know what your code is doing. But I think if you could sperate your code to a function from your form, then you can put your the function in Main just after the form show. Something like this

        Public Shared Sub Main(
        Dim myForm As New Form
        myForm.Show(

        myForm.myFuncti on(

        End Sub

        Comment

        • John

          #5
          RE: load form

          I don't know what your code is doing. But I think if you could sperate your code to a function from your form, then you can put your the function in Main just after the form show. Something like this

          Public Shared Sub Main(
          Dim myForm As New Form
          myForm.Show(

          myForm.myFuncti on(

          End Sub

          Comment

          Working...