Results 1 to 4 of 4

Thread: Form Freezing, with spreadsheet component

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    3

    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

  2. #2
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    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]

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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:
    1. If lngCounter Mod 1000 = 0 Then
    2.     DoEvents
    3. End If
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    3

    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
  •  



Click Here to Expand Forum to Full Width