On form load help

Ford-p

Active member
Joined
Mar 1, 2007
Messages
30
Programming Experience
Beginner
I have a form with a "Update" button which when clicked opens the following form:

VB.NET:
Public Class Updating

    Public Function Download(ByVal strURL As String) As String
        Dim objWeb As New System.Net.WebClient()
        Dim objStream As System.IO.Stream = objWeb.OpenRead(strURL)
        Dim strText As String
        Dim objReader As System.IO.StreamReader = New System.IO.StreamReader(objStream, System.Text.Encoding.UTF7, False)
        strText = objReader.ReadToEnd()
        Return strText
    End Function

    Private Sub Updating_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim strKeyCfg As String = Download("http://www.madink.co.uk/keyfinder/keys.cfg")
        Dim strLocation As String = Application.StartupPath & "\keys.cfg"

        Dim objWrite As System.IO.StreamWriter
        objWrite = IO.File.CreateText(strLocation)
        objWrite.WriteLine(strKeyCfg)
        objWrite.Close()

        MsgBox("Sucessfully updated '" & strLocation & "'.", 0)

        Me.Close()

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

End Class
My problem is that the form doesn't display until the file is downloaded and the MsgBox pops up. Is there a way to display the form and then run the code? Or a 1 second time delay before executing the code?

Thanks,
Joe :)
 
Back
Top