|
-
Jun 30th, 2005, 03:28 AM
#1
Thread Starter
New Member
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
-
Jun 30th, 2005, 04:36 AM
#2
Fanatic Member
Re: Form Freezing, with spreadsheet component
Place DoEvents somewhere in the do loop. This should release the freezing.
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
-
Jun 30th, 2005, 04:49 AM
#3
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
-
Jun 30th, 2005, 05:22 AM
#4
Thread Starter
New Member
Re: Form Freezing, with spreadsheet component
Thank you very much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|