General discussion

  • Creator
    Topic
  • #2316867

    DoEvents and Form Unload / visual basic

    Locked

    by rakesh2000_2000 ·

    One, I’ve a loop loading 10,000 data in the grid.
    second, i used doevents in the loop so that user can navigate grid as he views the records..
    third, if user at same time tries to close the form the form is getting closed and it shows the error of commandtext and form is again loaded and grid continues to load data it left it when form was closed.

    fourth, third point has screwed me.

    Please heeeeeeeeeeeeeeeeelp

All Comments

  • Author
    Replies
    • #2739310

      Reply To: DoEvents and Form Unload / visual basic

      by jackofalltech ·

      In reply to DoEvents and Form Unload / visual basic

      You’ll have to put code in the loop to check if the form is still open. There are several possible ways to do this, check the help for form methods and properties.

      Ralph

    • #3379624

      Reply To: DoEvents and Form Unload / visual basic

      by rrv ·

      In reply to DoEvents and Form Unload / visual basic

      10000 rows loading will not be that slow for the user to have time to scroll and close the form. You have to follow some methods of programming. Use MSHFLEXGRID to load the data. before loading use grid.redraw = false. and remember to set it to true when finisht. then set grid.datasouce=myrecordset. in case you do not have recordset and have data at run time to load you can still use doevents.
      grid.redraw=false
      grid.rows=2
      do while not EOF
      grid.textarray(CurRow*grid.cols+1)=col1value
      grid.textarray(CurRow*grid.cols+2)=col2value
      if (grid.rows mod 200)=0 then
      grid.redraw=true
      doevents
      grid.redaw=false
      endif
      movenext
      grid.rows=grid.rows+1
      loop
      grid.redraw=true

      In the unload event of the form use the below code
      if RcdSet.State = adStateOpen then
      RcdSet.close
      endif

      This method will sure help you.

      All the best
      RV

Viewing 1 reply thread