Perform automatic function After form loads?

Posted on 2005-05-05
Last Modified: 2010-04-23
I have an SQL connection that I need to run on my form when the form loads but if I put it in the form load sub the form doesn't show up untill the connection is complete or an error occurs.

How can I automatically run the function but allow the user to see the form while it runs?
Question by:Matrix1000
    LVL 4

    Assisted Solution

    Try setting

    Form.Visible = True

    in the Load event before you create the connection.
    LVL 38

    Accepted Solution

    If you put me.visible = true in form_load before connection, then the form will show before making the connection.  You might want an Application.DoEvents or even Me.Refresh to make sure the form is painted before making the connection.  Simple example:

      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Text = "HAHAHA"
            Me.Visible = True
            Me.Text = "Form1"

        End Sub

    If you comment out Me.Visible, then you won't see the form until 3 seconds has elapsed and the title is back to Form1

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now