Hi,

I have a form where I generate a report on some button click. I need help with the code to show another Form in Modal Form, And Place Progress bar on that and Increment the status, from calling form so that when progress bar is running user cannot close the form (where I placed button for showing report).
To calculate progressbar's percentage is in the form where button to show report is.

please help.
I hope i put my prob sensibly.

Recommended Answers

All 4 Replies

Loading a modal form, just like loading a MsgBox, it will stop all running code until that form is closed.
Why not have your code within your modal Form and run the code right after you load this Form?

Hi, Thanx for the reply.
Could you please help me with some sample code how to get data from main form into modal form to calculate progressbar % and how to call modal from from a form so that user cannot closes main form until progressbar complrtes.

Thanks

See if this helps.
2 Forms(1 ProgressBar on Form2)

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Visible = True '// for testing.  Displays Form, then displays Form2.
        Form2.ShowDialog()
    End Sub

    Public Sub startCoolProgressBarCode(ByVal myCoolProgressBar As ProgressBar)
        '// Add ProgressBar code here.
        '//------- For testing purposes.
        For i As Integer = 0 To myCoolProgressBar.Maximum
            myCoolProgressBar.Value = i
            Threading.Thread.Sleep(50) '// pauses entire app..  not recommended, just used for testing.
        Next '---------\\
        Form2.Close() '// Close Form2 once done.
    End Sub
End Class
Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '// Disable the ControlBox and set the Form to .Visible before calling the Sub on Form1.
        Me.ControlBox = False : Me.Visible = True
        Form1.startCoolProgressBarCode(Me.ProgressBar1)
    End Sub
End Class

tanxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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.