Form Freezing, with spreadsheet component
Hello
I use two spreedsheets in my vb program , and ervery form includes 3000 rows
and there are two loops workin with the two speedshets,
When i start the loop , the application freez , is there anyway to solve this??
the program need about 2-3 hours the get the result.
this is the code:
Dim colcount As Integer
Dim rowcount As Integer
Dim colc As Integer
Dim rowc As Integer
Dim temp As Integer
Private Sub Command1_Click()
Command1.Enabled = False
colcount = 2
rowcount = 1
colc = 2
rowc = 1
Text1.Text = newsheet.Cells(rowcount, 2).Value
Do
Do While old.Cells(rowc, colc).Value <> ""
If newsheet.Cells(rowcount, 2).Value = old.Cells(rowc, 2).Value And newsheet.Cells(rowcount, 4).Value = old.Cells(rowc, 4).Value Then
newsheet.Cells(rowcount, 9).Value = old.Cells(rowc, 9).Value
newsheet.Cells(rowcount, 10).Value = old.Cells(rowc, 10).Value
newsheet.Cells(rowcount, 11).Value = old.Cells(rowc, 11).Value
newsheet.Cells(rowcount, 12).Value = old.Cells(rowc, 12).Value
newsheet.Cells(rowcount, 13).Value = old.Cells(rowc, 13).Value
newsheet.Cells(rowcount, 14).Value = old.Cells(rowc, 14).Value
'temp = rowc
Exit Do
Form1.Refresh
End If
rowc = rowc + 1
Loop
rowc = 1
rowcount = rowcount + 1
Form1.Refresh
Loop While newsheet.Cells(rowcount, colcount).Value <> ""
Command1.Enabled = True
End Sub
Re: Form Freezing, with spreadsheet component
Place DoEvents somewhere in the do loop. This should release the freezing.
Re: Form Freezing, with spreadsheet component
DoEvents discussion.
You could reduce overhead greatly by "calling" DoEvents after certain number of iterations in the loop:
VB Code:
If lngCounter Mod 1000 = 0 Then
DoEvents
End If
Re: Form Freezing, with spreadsheet component