 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: VB slowness problem
A VB Program can be just a module. And since no UI is visible, a form isn't needed anyway.
If you remove the forms you could also check the "Unattended execution" in the properties (not required though - just suppresses any error messages from being displayed to written to an event log), also you have to change the startup to Sub Main() and have a Private Sub Main() in a module.
[also]
(I have seen some problems with VB and Client Access (IBM) for AS400's, so there may be a conflict with another program, test it on a non-server if possible to see if there's the same problem, compare software, etc)
[Edited by JLRodgers on 28-05-2003 at 03:21 PM GMT]
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
28-05-2003 at 09:20 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: VB slowness problem
Two things:
Both of the below can get a program to go from 100% usage to under 5%. Your code runs without giving the system control. This should fix it.
1) Put in DoEvents
2) Use the Sleep API
As a general tip, I always have a
whenever I have a do loop.
The below code is overkill... but if a routine does sometime that's outside your program, you can't control the processor usage.
'Declarations
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'EX:
Do While RunProgram
DoEvents
If datediff("n", t1, now)>=1 then
DoEvents
Sleep 1
'do in a one-minute interval
Go to DB1 get Values
DoEvents
Sleep 1
'how are you getting these values? through a dsn?
Process Values
DoEvents
Sleep 1
'what kind of processing?
Store results into DB2
DoEvents
Sleep 1
'Perhaps your connection may be the problem
t1=now
end if
DoEvents
Sleep 1
Check RunProgram
Loop
End Sub
|
[Edited by JLRodgers on 29-05-2003 at 12:47 PM GMT]
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
29-05-2003 at 06:46 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: VB slowness problem
And for anyone who wonders... the DoEvents/Sleep API does make the VB program run a bit slower - normally not noticable, or if it is, the user won't care since they can actually do other things on the PC at the same time.
But that's to be expected since you're telling the program to wait until the system processes other things before continuing.
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
29-05-2003 at 08:56 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: VB slowness problem
Only have code windows (not forms) visible and it goes a lot quicker. Just have the code of recently modified code open and it's quicker still.
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
30-05-2003 at 01:41 AM |
|
|
|
|
 |
 |