jana
asked on
Best way to continual loop capture error status and ok to save in VB.net
We have a routine then saves a series of data to SQL tables. However, we want to place some sort of search of status to know if ok to save. This "search" since it will be looking continual loop until status is reached, need to have some way to exit the loop.
This is in VB.NET
This is in VB.NET
ASKER
The routine in SAVE button is as follows:
The end result is that we want to run SAVE only if a certain record or row has been unlocked
Also we would like some sort of keypress incase the row is not locked and user can press ESC to continue some other time
Please adive
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Do Until RecordBeenUnlocked Is True
Call CheckIfRecordBeenUnlock() 'here where var 'RecordBeenUnlocked' if set to true or false
Loop
'Save if only recoerd has been unlock
Call SaveAllTransToSQL()
End Sub
The end result is that we want to run SAVE only if a certain record or row has been unlocked
Also we would like some sort of keypress incase the row is not locked and user can press ESC to continue some other time
Please adive
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Not in the computer to try, but was asked that since there is a call to a routine that performs a series of update to SQL tables, that the Save Button routine should be placed in a thread.
Can you give us your point of view?
Can you give us your point of view?
ASKER
Also can you give us a brief explanation of Application.DoEvents()?
ASKER
We have the following recommended script (es ID: 37857666) to run thru and exit on 2 condition:
1. If the user press ESC
2. If CheckIfRecordBeenUnlock routine (checks if record unlock) is trur
We would like if EE can assist us in these 3 last doubts we have so we can close:
1. How can we place a message form, not MsgBox, that will show while the
loop "Do Until RecordBeenUnlocked" is running and will not affect the actual loop.
2. We were recommnended to place this script within a Thread since a subroutine
within the loop doeas actual SQL tables update. Can EE give us a point of view on the
following (that is, if its tru or should we consider it)?
3. In the recommended script, there is a "Application.DoEvents()", we assume this
is so the user when pressing ESC it exits the Loop; however, we were told that it a bad
way or dangerous way to place Application.DoEvents() in our code. Can EE give
us thier opinion?
Thanx in advance
1. If the user press ESC
2. If CheckIfRecordBeenUnlock routine (checks if record unlock) is trur
We would like if EE can assist us in these 3 last doubts we have so we can close:
1. How can we place a message form, not MsgBox, that will show while the
loop "Do Until RecordBeenUnlocked" is running and will not affect the actual loop.
2. We were recommnended to place this script within a Thread since a subroutine
within the loop doeas actual SQL tables update. Can EE give us a point of view on the
following (that is, if its tru or should we consider it)?
3. In the recommended script, there is a "Application.DoEvents()", we assume this
is so the user when pressing ESC it exits the Loop; however, we were told that it a bad
way or dangerous way to place Application.DoEvents() in our code. Can EE give
us thier opinion?
Thanx in advance
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
But should we consider placing this short script within thread?
Also the "apps...DoEvent", is there a dangour placing it as it is?
Also the "apps...DoEvent", is there a dangour placing it as it is?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Unfortunately we haven't yet tested it, but this script while in a loop, if the user presses ESC, it would exit the loop; right?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanx!
>need to have some way to exit the loop.
Depending on loop, you can use
Exit For
Exit While
etc