As of right now, I have made a messagebox from a form that gives me the option to input new records into my table from an excel sheet or convert it over to a brand new table.
here is the code:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Maximum = Form1.totalrecords
ProgressBar1.Increment(1)
If ProgressBar1.Value = ProgressBar1.Maximum Then
Timer1.Stop()
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Form1.import_new_table()
Form1.divide_temp_table_into_other_tables()
Timer1.Start()
End Sub
the
Form1.totalrecords
is based upon the total rows in the excel sheet that is being copied to the database.
The issue that I am having is the screen freezes until the process is done and the progress bar seems to start after the table has been imported.
Any suggestions?
What I have tried:
I have tried to set the minimum value and step into the maximum value but this problem seems to be persistent.
[EDIT AFTER SOLUTION 1]
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
BackgroundWorker1.RunWorkerAsync()
Form1.import_new_table()
Form1.divide_temp_table_into_other_tables()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
For x As Integer = 0 To 100
System.Threading.Thread.Sleep(100)
BackgroundWorker1.ReportProgress(CInt(x / Form1.totalrecords) * 100)
Next
End Sub
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub
Private Sub Import_excel_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ProgressBar1.Maximum = Form1.totalrecords
End Sub
however, The progress bar is not moving, and now the memory much larger it was around 152 mb and now it shoots up to 9 - 10 gb.