I've got a little issue with a progress bar.I have a label and the progress bar on a form.I've some calculation to be performed and then stored to the database.I wanted to show the progress of this process to the user.The calculation process is on another form.when the process starts i displayed the form but it shows the progress after the records are saved to the database.
How can i achieve this along with the calculation?Here are the codes i used.
The code below calls a procedure to read records from an excel file,then calls another procedure to perform the calculation on a row basis:
Public Sub importToDb(ByVal district As String) dt = New DataTable Windows.Forms.Cursor.Current = Cursors.WaitCursor dt = ReadExcel(district) total = dt.Rows.Count For i = 0 To dt.Rows.Count - 1 If Not IsDBNull(dt.Rows(i)(0)) Then calculatesave(i, district) frmProgress.Timer1.Start() frmProgress.Show() frmProgress.BringToFront() End If Next dt = Nothing End Sub
This is the code related to the progress bar in another form,placed in a timer tick event:
Me.ProgressBar1.Maximum = frmBridge.total If Me.ProgressBar1.Value >= Me.ProgressBar1.Maximum Then Me.Timer1.Stop() MessageBox.Show("Importing Successful") Me.Close() Me.Timer1.Stop() Else Me.ProgressBar1.Value = Me.ProgressBar1.Value + 1 Label1.Text = "Importing " & Me.ProgressBar1.Value & " of " & Me.ProgressBar1.Maximum End If