|
-
August 16th, 2001, 03:43 AM
#1
Background processing
I have the following code:
private Sub cmdLink_Click()
on error GoTo ErrorHandler
Dim Source as string
cdlGetFile.DialogTitle = "Link Database"
cdlGetFile.InitDir = App.Path
cdlGetFile.Filter = "database|link.mdb"
cdlGetFile.ShowOpen
Source = cdlGetFile.FileName
ImportCPLink Source
Exit Sub
ErrorHandler:
MsgBox Err.Description, vbCritical, "error"
Exit Sub
End Sub
...
private Sub ImportCPLink(Source as string)
set dbsLink = OpenDatabase(Source)
set rstCompany = dbsLink.OpenRecordset("COMPANY", dbOpenForwardOnly)
Do While Not rstCompany.EOF
' do all sorts of stuff
rstCompany.MoveNext
Loop
rstCompany.Close
dbsLink.Close
End Sub
Everything works fine BUT (there's always a but) my window isn't updated while the program is processing the while loop. Since I'm fairly new to VB I don't know a way to put the processing in the background or another way to update the GUI.
Please help out a C++ programmer who is stuck with VB for now. Just as I rate answers in the VCC forums I will rate yours if it helps ;-)
-
August 16th, 2001, 04:15 AM
#2
Re: Background processing
The application probably "freezes" when doing the WHILE LOOP. You can use DoEvents to return control to the system to do some things like updating the screen. Just place it somewhere in the loop and things should be way better.
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
August 16th, 2001, 04:27 AM
#3
Re: Background processing
Thanks, it worked just fine. Nice to see other people from Belgium on the forums ;-)
BTW nice signature but there's a typo in there: idot-proof should probably be idiot-proof, if it's intentional just disregard the remark (DOH!)
-
August 16th, 2001, 04:32 AM
#4
Re: Background processing
Indeed nice to see some Belgium people here. About the sig, corrected it, unless i made another idiotic mistake, but hey, as the sig says, the universe is winning, and sometimes we all belong to the idiot part of the world.
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
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
|