I use visual studio 8.0
Two forms:

windows form => form1.vb
windows dialog form => ProcesDialog.vb
On the procesDiaglog are five label fields:
label1
label2
label3
label4
label5

Two picture fields
picture1
picture2

I want to show the progress of building a Windows form1
I would always show the progress in procesdiaglog
Problem is that Form1 does not become visible and procesdiaglog remains a blank screen (see Annex).
Form1 is so called: form1.show
For more information, see code from form1.vb.

Public Sub New()  
        ' This call is required by the Windows Form Designer.
        ' Add any initialization after the InitializeComponent() call.
         ' This call is required by the Windows Form Designer.
        InitializeComponent()
        ProcesDialog.Show()
        ProcesDialog.ProgressBar1.PerformStep()
        ProcesDialog.Label1.Text = "fase 1"
        ProcesDialog.Label2.Text = 0
        ProcesDialog.Label3.Text = "Percentage completed" & Int(ProcesDialog.ProgressBar1.Value * 100 / ProcesDialog.ProgressBar1.Maximum) & "%"
          For i = 1 To 1000000000
            If i = 10000 Then
                ProcesDialog.ProgressBar1.PerformStep()
                ProcesDialog.Label1.Text = "fase 2"
                ProcesDialog.Label2.Text = i
                ProcesDialog.Label3.Text = "Percentage completed" & Int(ProcesDialog.ProgressBar1.Value * 100 / ProcesDialog.ProgressBar1.Maximum) & "%"
                               Me.Refresh()
            End If

            If i = 100000 Then
                ProcesDialog.ProgressBar1.PerformStep()
                ProcesDialog.Label1.Text = "fase 3"
                ProcesDialog.Label2.Text = i
                ProcesDialog.Label3.Text = "Percentage completed" & Int(ProcesDialog.ProgressBar1.Value * 100 / ProcesDialog.ProgressBar1.Maximum) & "%"
                            End If

            If i = 7000000 Then
                ProcesDialog.ProgressBar1.PerformStep()
                ProcesDialog.Label1.Text = "fase 4"
                ProcesDialog.Label2.Text = i
                ProcesDialog.Label3.Text = "Percentage completed" & Int(ProcesDialog.ProgressBar1.Value * 100 / ProcesDialog.ProgressBar1.Maximum) & "%"
           End If
        Next

'Here Here comes the rest of the code ......
end sub

Thanks for the reply,

André

Attachments empty_Dialog.PNG 18.64 KB

You can use BackgroundWork,

Dim dlg As Form
    Dim pgr As ProgressBar
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        BackgroundWorker1.WorkerReportsProgress = True
        dlg = New Form()
        pgr = New ProgressBar
        pgr.Dock = DockStyle.Fill
        pgr.Minimum = 1
        pgr.Maximum = 100

        dlg.Owner = Me
        dlg.Size = New Size(150, 40)
        dlg.Controls.Add(pgr)
        dlg.Text = "Please wait"
        dlg.Show()

        BackgroundWorker1.RunWorkerAsync()

    End Sub
   

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        For i As Integer = 1 To 100
            Threading.Thread.Sleep(100)
            BackgroundWorker1.ReportProgress(i)
        Next
    End Sub

    Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
        pgr.Value = e.ProgressPercentage
        dlg.Text = e.ProgressPercentage & "%"
    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        dlg.Close()
    End Sub
This question has already been answered. Start a new discussion instead.