I have a form let's call it Form1 that calls another form(Form2)

Form2 to has a bit a code that needs to load in the LOAD_EVENT and takes about 4 seconds.

I have made a new form(frmProgress) that only has a progress bar.

I want frmProgress to show up and load the progress bar meanwhile Form2 is loading.

I've tried using BackgroundWorker but I can't seem to get the grasp of it.

Can someone please help me out. Thanks.

btw i've looked into some tutorials but don't fully understand it.

See if this helps.
2 Forms(ProgressBar on Form1)

Public Class Form1
    '// Timer to keep status of the ProgressBar.Value.
    Private WithEvents tmrStatus As New Timer With {.Interval = 100, .Enabled = True}

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// Form1 loading code here if needed.
        '// Run the following code last in Form1_Load.
        Me.Show() '// display Form before running the ProgressBar code, else it will run the code before Form1 displays.
        Form2.loadForm2(ProgressBar1) '// run the ProgressBar code.
    End Sub

    Private Sub tmrStatus_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrStatus.Tick
        If ProgressBar1.Value = 100 Then
            tmrStatus.Enabled = False
            Me.Hide() '// should be "Me.Close" if done with the Form.
            '// since all the code was loaded, you can close the ProgressBar Form and load the Form needed.
            Form2.Show()
        End If
    End Sub
End Class
Public Class Form2

    Public Sub loadForm2(ByVal ProgressBarToUse As ProgressBar)
        With ProgressBarToUse
            .Value = 0
            Threading.Thread.Sleep(450) '// FOR TESTING.
            '// run some code lines here.
            .Value = 10
            Threading.Thread.Sleep(450) '// FOR TESTING.
            '// run some more code lines here.
            .Value = 50
            Threading.Thread.Sleep(450) '// FOR TESTING.
            '// ""
            .Value = 70
            Threading.Thread.Sleep(450) '// FOR TESTING.
            '// ""
            .Value = 100
        End With
    End Sub
End Class

I ended up using a Timer since in my sample project's Properties, I have "when Form1 closes" to terminate the app..

That code will only make a progress bar to load but it doesn't have a backgroundworker to run a code meanwhile it loads.

The problem is that I have a function on Form2 that takes up a bit to load. So Form1 looks like it's frozen so that's why i want frmProgress to load meanwhile the function in Form2 is running.

Have you tried running the BackgroundWorker from Form1, instead of calling the loadForm2 Sub?

Have you tried running the BackgroundWorker from Form1, instead of calling the loadForm2 Sub?

I can't run the function on backgroundworker because it has controls :( ... I read its not easily possible

Try this thread, might be easier than you think.:)
.There is also another post of mine in that thread, just above the linked one.
Hope it helps.

commented: thanks +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.