473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

progress bars

i have been working with vb6 for a while but never had the pleasure of using
progress bars. That is until now, one of the programs i have written has
just been modified so that large csv files of 100,000+ lines can be imported
into a database.

the import works fine but the progress bar feature is not working correctly.
The progress bar is set to a max value of the number of records in the csv
file, the records are then imported and the progress bar runs from from zero
to max no problem.

however under the progress bar is a text box that should display the
percentage and update with each import loop but it doesnt update. it stays
blank until the full import is complete then it will show 100%. but if you
step through the program in debug mode the text box updates correctly.

has anyone had any joys with this control. any ideas will be appreciated.
the full import routine is too big to post so i have simplified the progress
bar into a loop if anyone wants to have a look.

Private Sub cmdStart_Click()
While ProgressBar1.Value < ProgressBar1.Max
Do
ProgressBar1.Value = ProgressBar1.Value + 1
txtPercentage.Text = (ProgressBar1.Value / ProgressBar1.Max) * 100 & "%"
Loop
Wend
End Sub

Cheers
Paul

Jul 17 '05 #1
16 24957
Hi Paul,

Comments inline...

--
To reply, take out the .OBVIOUS from the address.

"Paul" <pa**@pgcomputing.net> wrote in message news:1g*****************@news-binary.blueyonder.co.uk...
i have been working with vb6 for a while but never had the pleasure of using
progress bars. That is until now, one of the programs i have written has
just been modified so that large csv files of 100,000+ lines can be imported
into a database.

the import works fine but the progress bar feature is not working correctly.
The progress bar is set to a max value of the number of records in the csv
file, the records are then imported and the progress bar runs from from zero
to max no problem.

however under the progress bar is a text box that should display the
percentage and update with each import loop but it doesnt update. it stays
blank until the full import is complete then it will show 100%. but if you
step through the program in debug mode the text box updates correctly.

has anyone had any joys with this control. any ideas will be appreciated.
the full import routine is too big to post so i have simplified the progress
bar into a loop if anyone wants to have a look.

Private Sub cmdStart_Click()
While ProgressBar1.Value < ProgressBar1.Max
Do
ProgressBar1.Value = ProgressBar1.Value + 1
txtPercentage.Text = (ProgressBar1.Value / ProgressBar1.Max) * 100 & "%"
'Refresh the textbox
txtPercentage.Refresh

Regards,

Stoil
Loop
Wend
End Sub

Cheers
Paul




Jul 17 '05 #2
Thanks for that you are a star, i've spent most of the day looking at this
and i forget something as simple as a refresh. I can finally finish the
program now.

cheers

paul

"Stoil Marinov" <st*******************@firemail.de> wrote in message
news:be************@ID-24932.news.dfncis.de...
Hi Paul,

Comments inline...

--
To reply, take out the .OBVIOUS from the address.

"Paul" <pa**@pgcomputing.net> wrote in message
news:1g*****************@news-binary.blueyonder.co.uk...
i have been working with vb6 for a while but never had the pleasure of using progress bars. That is until now, one of the programs i have written has
just been modified so that large csv files of 100,000+ lines can be imported into a database.

the import works fine but the progress bar feature is not working correctly. The progress bar is set to a max value of the number of records in the csv
file, the records are then imported and the progress bar runs from from zero to max no problem.

however under the progress bar is a text box that should display the
percentage and update with each import loop but it doesnt update. it stays
blank until the full import is complete then it will show 100%. but if you
step through the program in debug mode the text box updates correctly.

has anyone had any joys with this control. any ideas will be appreciated.
the full import routine is too big to post so i have simplified the progress bar into a loop if anyone wants to have a look.

Private Sub cmdStart_Click()
While ProgressBar1.Value < ProgressBar1.Max
Do
ProgressBar1.Value = ProgressBar1.Value + 1
txtPercentage.Text = (ProgressBar1.Value / ProgressBar1.Max) * 100 & "%"

'Refresh the textbox
txtPercentage.Refresh

Regards,

Stoil
Loop
Wend
End Sub

Cheers
Paul

Jul 17 '05 #3
Hi Paul,
Try putting a DoEvents inside your loop. Otherwise VB is so busy with the
import that it doesn't have the time to update the progress bar.
Captain Proton

"Paul" <pa**@pgcomputing.net> schreef in bericht
news:1g*****************@news-binary.blueyonder.co.uk...
i have been working with vb6 for a while but never had the pleasure of using progress bars. That is until now, one of the programs i have written has
just been modified so that large csv files of 100,000+ lines can be imported into a database.

the import works fine but the progress bar feature is not working correctly. The progress bar is set to a max value of the number of records in the csv
file, the records are then imported and the progress bar runs from from zero to max no problem.

however under the progress bar is a text box that should display the
percentage and update with each import loop but it doesnt update. it stays
blank until the full import is complete then it will show 100%. but if you
step through the program in debug mode the text box updates correctly.

has anyone had any joys with this control. any ideas will be appreciated.
the full import routine is too big to post so i have simplified the progress bar into a loop if anyone wants to have a look.

Private Sub cmdStart_Click()
While ProgressBar1.Value < ProgressBar1.Max
Do
ProgressBar1.Value = ProgressBar1.Value + 1
txtPercentage.Text = (ProgressBar1.Value / ProgressBar1.Max) * 100 & "%" Loop
Wend
End Sub

Cheers
Paul

Jul 17 '05 #4
Paul wrote:

i have been working with vb6 for a while but never had the pleasure of using
progress bars. That is until now, one of the programs i have written has
just been modified so that large csv files of 100,000+ lines can be imported
into a database.

the import works fine but the progress bar feature is not working correctly.
The progress bar is set to a max value of the number of records in the csv
file, the records are then imported and the progress bar runs from from zero
to max no problem.


Cap'n showed you the .refresh answer to your direct question but I'd
suggest adding some logic to not update <every> pass through the
loop--every couple of percent or so should be often enough and you'll
save a fair amount of display overhead that will speed up the load
process to boot---I'm a pretty rudimentary guy wrt GUIs so I usually do
no more than 10% increments unless that takes so long that there's no
indication of movement--then I'll break it up somewhat finer. I'd much
prefer the machine to be doing something useful, not looking pretty, but
others preferences are the other way 'round, I know... :)
Jul 17 '05 #5
Hello,

Comments inline...

--
To reply, take out the .OBVIOUS from the address.

"CajunCoiler (http://www.cajuncoiler.tk)" <ca*********@totallyspamless.cox.net> wrote in message news:YE_Oa.9$N%3.5@lakeread01...
Somewhere between Do, and Loop, add in a DoEvents, and see if that
clears it up for ya. Essentially, the anamole you're experiencing is
due to the loop taking up a padload of CPU time... this leaves little to
no CPU time for the program to update the textbox. The DoEvents
function will relinquish the loop's monopoly long enough for other
things to go on, then resume it's reign over the O/S.

Once, before I was made aware of DoEvents, I had written a program
with a loop in it that took 4-1/2 days to complete. While it ran, nothing
else had been serviced, and by the time it completed, the real-time
clock was 26 hours in arrears. Adding that one function bumped up
the execution time only slightly, but all other processes were being
serviced, and the real-time clock stayed on the mark.
This must have been on a 16 bit Windows.
On 32 bit Windows preemptive multi-tasking is used. Each process is given a slice of the CPU time without regard whether it is in a tight loop or idle. So, DoEvents will not matter in that regard.
On 32 bit Windows DoEvents lets the message loop behind the thread's window process the messages on the message queue.
In this case it is the WM_PAINT message responsible for repainting the Textbox with the new percentage value.
If that is all that is needed, it is better to simply use the Refresh method of the Textbox after setting its value. This has less overhead compared to DoEvents, since only messages regarding the Textbox control are processed. Also it avoids one nasty side effect of DoEvents - reentrance and/or branching to other events code, which, if unaware, could be a real pain.

Regards,

Stoil

"Paul" <pa**@pgcomputing.net> wrote in message
news:1g*****************@news-binary.blueyonder.co.uk...
i have been working with vb6 for a while but never had the pleasure of

using
progress bars. That is until now, one of the programs i have written has
just been modified so that large csv files of 100,000+ lines can be

imported
into a database.

the import works fine but the progress bar feature is not working

correctly.
The progress bar is set to a max value of the number of records in the csv
file, the records are then imported and the progress bar runs from from

zero
to max no problem.

however under the progress bar is a text box that should display the
percentage and update with each import loop but it doesnt update. it stays
blank until the full import is complete then it will show 100%. but if you
step through the program in debug mode the text box updates correctly.

has anyone had any joys with this control. any ideas will be appreciated.
the full import routine is too big to post so i have simplified the

progress
bar into a loop if anyone wants to have a look.

Private Sub cmdStart_Click()
While ProgressBar1.Value < ProgressBar1.Max
Do
ProgressBar1.Value = ProgressBar1.Value + 1
txtPercentage.Text = (ProgressBar1.Value / ProgressBar1.Max) * 100 &

"%"
Loop
Wend
End Sub

Cheers
Paul




Jul 17 '05 #6
As others have stated, DoEvents statements will make it work better.
However, an alternative is to use a better progressbar control with
other abilities besides the very rudimentary one that comes with VB.

I have made such a control for my own use, but it is not quite perfect
yet. It works fine, but visually it needs some work.

You can get plenty of free progressbar controls that are much more
robust than the included one. Just search on the web for them.

On Wed, 9 Jul 2003 20:43:50 +0100, "Paul" <pa**@pgcomputing.net>
wrote:
i have been working with vb6 for a while but never had the pleasure of using
progress bars. That is until now, one of the programs i have written has
just been modified so that large csv files of 100,000+ lines can be imported
into a database.

the import works fine but the progress bar feature is not working correctly.
The progress bar is set to a max value of the number of records in the csv
file, the records are then imported and the progress bar runs from from zero
to max no problem.

however under the progress bar is a text box that should display the
percentage and update with each import loop but it doesnt update. it stays
blank until the full import is complete then it will show 100%. but if you
step through the program in debug mode the text box updates correctly.

has anyone had any joys with this control. any ideas will be appreciated.
the full import routine is too big to post so i have simplified the progress
bar into a loop if anyone wants to have a look.

Private Sub cmdStart_Click()
While ProgressBar1.Value < ProgressBar1.Max
Do
ProgressBar1.Value = ProgressBar1.Value + 1
txtPercentage.Text = (ProgressBar1.Value / ProgressBar1.Max) * 100 & "%"
Loop
Wend
End Sub

Cheers
Paul


---Atreju---
Jul 17 '05 #7
Paul,

Inside of your Do-Loop right after you set txtPercentage.Text try doing
a DoEvents. DoEvents causes VB to pause long enough for the operating
system to process other events (messages). When you change text that is
doing text_change event so that event is pending.

For Example try:

Private Sub cmdStart_Click()
While ProgressBar1.Value < ProgressBar1.Max
Do
ProgressBar1.Value = ProgressBar1.Value + 1
txtPercentage.Text = (ProgressBar1.Value / ProgressBar1.Max) * 100 & "%"
DoEvents
Loop
Wend
End Sub


Paul wrote:
i have been working with vb6 for a while but never had the pleasure of using
progress bars. That is until now, one of the programs i have written has
just been modified so that large csv files of 100,000+ lines can be imported
into a database.

the import works fine but the progress bar feature is not working correctly.
The progress bar is set to a max value of the number of records in the csv
file, the records are then imported and the progress bar runs from from zero
to max no problem.

however under the progress bar is a text box that should display the
percentage and update with each import loop but it doesnt update. it stays
blank until the full import is complete then it will show 100%. but if you
step through the program in debug mode the text box updates correctly.

has anyone had any joys with this control. any ideas will be appreciated.
the full import routine is too big to post so i have simplified the progress
bar into a loop if anyone wants to have a look.

Private Sub cmdStart_Click()
While ProgressBar1.Value < ProgressBar1.Max
Do
ProgressBar1.Value = ProgressBar1.Value + 1
txtPercentage.Text = (ProgressBar1.Value / ProgressBar1.Max) * 100 & "%"
Loop
Wend
End Sub

Cheers
Paul



Jul 17 '05 #8

You've guessed wrong... it was indeed done in 32-bit.

"CajunCoiler (http://www.cajuncoiler.tk)"
<ca*********@totallyspamless.cox.net> wrote in message
news:YE_Oa.9$N%3.5@lakeread01...
Once, before I was made aware of DoEvents, I had written a program
with a loop in it that took 4-1/2 days to complete. While it ran, nothing
else had been serviced, and by the time it completed, the real-time
clock was 26 hours in arrears. Adding that one function bumped up
the execution time only slightly, but all other processes were being
serviced, and the real-time clock stayed on the mark.


This must have been on a 16 bit Windows.
On 32 bit Windows preemptive multi-tasking is used. Each process is given a
slice of the CPU time without regard whether it is in a tight loop or idle.
So, DoEvents will not matter in that regard.
Jul 17 '05 #9


--
To reply, take out the .OBVIOUS from the address.

"CajunCoiler (http://www.cajuncoiler.tk)" <ca*********@totallyspamless.cox.net> wrote in message news:7ffPa.584$N%3.550@lakeread01...

You've guessed wrong... it was indeed done in 32-bit.

"CajunCoiler (http://www.cajuncoiler.tk)"
<ca*********@totallyspamless.cox.net> wrote in message
news:YE_Oa.9$N%3.5@lakeread01...
Once, before I was made aware of DoEvents, I had written a program
with a loop in it that took 4-1/2 days to complete. While it ran, nothing
else had been serviced, and by the time it completed, the real-time ^^^^^^^^^^^^^^^^^^^^^^^
Well, then this statement of yours is wrong.

Regards,

Stoil
clock was 26 hours in arrears. Adding that one function bumped up
the execution time only slightly, but all other processes were being
serviced, and the real-time clock stayed on the mark.


This must have been on a 16 bit Windows.
On 32 bit Windows preemptive multi-tasking is used. Each process is given a
slice of the CPU time without regard whether it is in a tight loop or idle.
So, DoEvents will not matter in that regard.



Jul 17 '05 #10
Once, before I was made aware of DoEvents, I had written a program
with a loop in it that took 4-1/2 days to complete. While it ran, nothing else had been serviced, and by the time it completed, the real-time
^^^^^^^^^^^^^^^^^^^^^^^ Well, then this statement of yours is wrong.


I don't recall you being here when it happened, so you are in no position
whatsoever to say what did and didn't happen. For this same reason,
you are also in no position to claim whether my statement is right or wrong.

You weren't here, you haven't seen my code. If you claim otherwise, then
you are confessing to monitoring my actions, and my code during development,
and I would have to press charges... which is it going to be?
Jul 17 '05 #11


--
To reply, take out the .OBVIOUS from the address.

"CajunCoiler (http://www.cajuncoiler.tk)" <ca*********@totallyspamless.cox.net> wrote in message news:36jPa.1800$N%3.784@lakeread01...
Once, before I was made aware of DoEvents, I had written a program
with a loop in it that took 4-1/2 days to complete. While it ran, nothing else had been serviced, and by the time it completed, the real-time
^^^^^^^^^^^^^^^^^^^^^^^
Well, then this statement of yours is wrong.


I don't recall you being here when it happened, so you are in no position
whatsoever to say what did and didn't happen. For this same reason,
you are also in no position to claim whether my statement is right or wrong.

You weren't here, you haven't seen my code. If you claim otherwise, then
you are confessing to monitoring my actions, and my code during development,
and I would have to press charges... which is it going to be?


Interesting logic <g>.

When a certain physical process is governed by some fundamental principle, one does not need to observe it personally in order to know what the outcome will be.

In this particular case you have two statements that are in contradiction. Either your program was running on a 16 bit Windows, where DoEvents were needed to let other programs get CPU time too. Or, if your program did run on 32 bit Windows, then the effects you describe are simply not possible. Adding DoEvents (or not) in your program, running on 32 bit Windows, which employs preemptive multi-tasking, does not have any effect on the amount of CPU time used by any other running process.
In other words, you cannot prevent other running processes from getting CPU time even if your program was in a tight loop with no DoEvents whatsoever.
You might want to search on google.com on this subject or read some books if you do not believe me.

Regards,

Stoil



Jul 17 '05 #12
"Stoil Marinov" <st*******************@firemail.de> wrote in message <news:be************@ID-24932.news.uni-berlin.de>...
In this particular case you have two statements that are in contradiction. Either
your program was running on a 16 bit Windows, where DoEvents were needed
to let other programs get CPU time too. Or, if your program did run on 32 bit
Windows, then the effects you describe are simply not possible. Adding
DoEvents (or not) in your program, running on 32 bit Windows, which employs
preemptive multi-tasking, does not have any effect on the amount of CPU time
used by any other running process.
In other words, you cannot prevent other running processes from getting CPU
time even if your program was in a tight loop with no DoEvents whatsoever.
You might want to search on google.com on this subject or read some books
if you do not believe me.


Actually, I have seen some strange behavior in Lose98 that went
away once I added DoEvents to a long-running loop. Internet
Exploiter couldn't open a new window, or something like that.

--
Joe Foster <mailto:jlfoster%40znet.com> Space Cooties! <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!
Jul 17 '05 #13
On Thu, 10 Jul 2003 21:11:22 -0700, "Joe \"Nuke Me Xemu\" Foster"
<jo*@bftsi0.UUCP> wrote:
"Stoil Marinov" <st*******************@firemail.de> wrote in message <news:be************@ID-24932.news.uni-berlin.de>...
In this particular case you have two statements that are in contradiction. Either
your program was running on a 16 bit Windows, where DoEvents were needed
to let other programs get CPU time too. Or, if your program did run on 32 bit
Windows, then the effects you describe are simply not possible. Adding
DoEvents (or not) in your program, running on 32 bit Windows, which employs
preemptive multi-tasking, does not have any effect on the amount of CPU time
used by any other running process.
In other words, you cannot prevent other running processes from getting CPU
time even if your program was in a tight loop with no DoEvents whatsoever.
You might want to search on google.com on this subject or read some books
if you do not believe me.


Actually, I have seen some strange behavior in Lose98 that went
away once I added DoEvents to a long-running loop. Internet
Exploiter couldn't open a new window, or something like that.

Yep i remember similar things too, but could you refresh my memory on
which 9x OS was actually 32 bit ? ;-p

--

Regards, Frank
Jul 17 '05 #14
On Fri, 11 Jul 2003 05:11:36 GMT, fa**@xxxxoptushome.com.au (Frank
Adam) wrote:

<snip>
Yep i remember similar things too, but could you refresh my memory on
which 9x OS was actually 32 bit ? ;-p

Yes, it is terrifying seen the list of running 16 bit DLLs ....--

Regards, Frank


Jul 17 '05 #15
On Fri, 11 Jul 2003 08:19:09 +0000 (UTC)
Bo*************@iss.u-net.com_.bin (J French) wrote:
On Fri, 11 Jul 2003 05:11:36 GMT, fa**@xxxxoptushome.com.au (Frank
Adam) wrote:

<snip>

Yep i remember similar things too, but could you refresh my memory on
which 9x OS was actually 32 bit ? ;-p

Yes, it is terrifying seen the list of running 16 bit DLLs ....
--

Regards, Frank

I must say that I agree fully with the original poster in this sub-thread. DoEvents has cleared up (unexplainably) a few problems with some our code in the past. Windows is strange indeed.

--
Regards, Jordan Timothy Cox
Programmer & IT Administrator,
Geronimo Development Corporation (http://casefinder.com)
Jul 17 '05 #16
On Sun, 20 Jul 2003 14:56:47 -0500, "Jordan T. Cox"
<jc**@casefinder.com> wrote:
On Fri, 11 Jul 2003 08:19:09 +0000 (UTC)
Bo*************@iss.u-net.com_.bin (J French) wrote:
On Fri, 11 Jul 2003 05:11:36 GMT, fa**@xxxxoptushome.com.au (Frank
Adam) wrote:

<snip>
>>
>Yep i remember similar things too, but could you refresh my memory on
>which 9x OS was actually 32 bit ? ;-p
> Yes, it is terrifying seen the list of running 16 bit DLLs ....
>--
>
>Regards, Frank

I must say that I agree fully with the original poster in this sub-thread.
DoEvents has cleared up (unexplainably) a few
problems with some our code in the past. Windows is strange indeed.


Yes, they can often be due to cascading events

One tip I have found useful is to allow multiple calls to set things
up, and set off a Timer, so that one only 'continues' when things have
settled down.
In some ways an alternative to DoEvents
- although in this case Label1.Refresh is the obvious answer
Jul 17 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Martin Platt | last post by:
Hi, I'm looking into various options for a fairly simple backup utility for our application. I have no problems being able to backup, find restorable backup files, and restore then. What I'd...
1
by: Xarky | last post by:
Hi, I am trying to use progress bars, where the progress is seen as vertical. I am succeding to manage progess bars, where progress is increasing horizontally, but not vertically. Can someone...
5
by: Søren Reinke | last post by:
Hi there I am working on a program where the user should be able to import some CSV files. With my set of test data, it takes about 2 minutes to import, while it is importing the program sort...
6
by: Kyle | last post by:
I want to do a single pix update bar instead of the big block that progress bars usually use. I can't seem to find any info on how to do this. Thanks in advance for any help, Kyle
4
by: aj | last post by:
Alan, you can achieve this by using XMLHttp Async functionality in a javascript file. Create an aspx page in which execute long running SQL query, then do an XMLhttp post to that page from a js...
2
by: Robert Smith | last post by:
Hello, I have a problem with my progress bar, as shown in the attached code, the values on the bar are incremented within a threaded timer event. The timer works fine and ticks all the way...
5
by: Keith Rebello | last post by:
I have a couple of progress bars that indicate the progress of a math-intensive application. They are working well. The only problem is that the progress indicator is gray in color. Is it...
6
by: Marko Vuksanovic | last post by:
I am trying to implement a file upload progress indicator (doesn't have to be a progress bar) using atlas... I do realize that the indicator cannot be implemented using Update panel control, but is...
3
by: Ritesh Raj Sarraf | last post by:
Hi, I have a small application, written in Python, that uses threads. The application uses function foo() to download files from the web. As it reads data from the web server, it runs a progress...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.