Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Detecting Input while In A loop

Hi

I am writing an application in VB, which requires to be in a loop for what could be a long period. The program goes through the following steps:

Loads A Form
( the form has two buttons Start and Stop )

If the user clicks on start the programs calls a function as to do the following:

Opens a server based SQL database
Loop start
Checks that new records exist
Gets a set of records using a Query
Processes these
Updates a second server based database
Displays various Output on Form
Loop End

The problem I am having is that once in the loop, the program does not respond to any input and its not possible to use the stop button, move the form, close the program etc.

I would appreciate if anyone could assist in outlining how I can keep the program responding to user input one inside a loop.


thanks



Comments

  • paulj59paulj59 Member Posts: 420
    : Hi
    :
    : I am writing an application in VB, which requires to be in a loop for what could be a long period. The program goes through the following steps:
    :
    : Loads A Form
    : ( the form has two buttons Start and Stop )
    :
    : If the user clicks on start the programs calls a function as to do the following:
    :
    : Opens a server based SQL database
    : Loop start
    : Checks that new records exist
    : Gets a set of records using a Query
    : Processes these
    : Updates a second server based database
    : Displays various Output on Form
    : Loop End
    :
    : The problem I am having is that once in the loop, the program does not respond to any input and its not possible to use the stop button, move the form, close the program etc.
    :
    : I would appreciate if anyone could assist in outlining how I can keep the program responding to user input one inside a loop.
    :
    :
    : thanks
    :
    :
    :
    :
    Put a DoEvents in the loop.
    Be aware that your Start button could be pressed and your routine reentered. Either disable the Start button, or set a Static or module level variable to indicate that you are still in the loop.
  • paulj59paulj59 Member Posts: 420
    : Hi
    :
    : I am writing an application in VB, which requires to be in a loop for what could be a long period. The program goes through the following steps:
    :
    : Loads A Form
    : ( the form has two buttons Start and Stop )
    :
    : If the user clicks on start the programs calls a function as to do the following:
    :
    : Opens a server based SQL database
    : Loop start
    : Checks that new records exist
    : Gets a set of records using a Query
    : Processes these
    : Updates a second server based database
    : Displays various Output on Form
    : Loop End
    :
    : The problem I am having is that once in the loop, the program does not respond to any input and its not possible to use the stop button, move the form, close the program etc.
    :
    : I would appreciate if anyone could assist in outlining how I can keep the program responding to user input one inside a loop.
    :
    :
    : thanks
    :
    :
    :
    :

    PS
    Consider creating a Linked server and update the records from one server to the other in one query as opposed to reading them in one one connection and writing on another. Works very well if simple inserts, not so good on more complicated queries because the indexes on the linked server won't be used.
  • andymckandymck Member Posts: 2
    THanks for your help, much appreciated!


    : : Hi
    : :
    : : I am writing an application in VB, which requires to be in a loop for what could be a long period. The program goes through the following steps:
    : :
    : : Loads A Form
    : : ( the form has two buttons Start and Stop )
    : :
    : : If the user clicks on start the programs calls a function as to do the following:
    : :
    : : Opens a server based SQL database
    : : Loop start
    : : Checks that new records exist
    : : Gets a set of records using a Query
    : : Processes these
    : : Updates a second server based database
    : : Displays various Output on Form
    : : Loop End
    : :
    : : The problem I am having is that once in the loop, the program does not respond to any input and its not possible to use the stop button, move the form, close the program etc.
    : :
    : : I would appreciate if anyone could assist in outlining how I can keep the program responding to user input one inside a loop.
    : :
    : :
    : : thanks
    : :
    : :
    : :
    : :
    :
    : PS
    : Consider creating a Linked server and update the records from one server to the other in one query as opposed to reading them in one one connection and writing on another. Works very well if simple inserts, not so good on more complicated queries because the indexes on the linked server won't be used.
    :

Sign In or Register to comment.