VB frontend for PERL script - progress bar

Currently i have a perl script that I am developing a Visual Basic frontend for.  Basically, all Visual Basic does is present forms to the user, in which data is entered, then writes that to file...  PERL waits for the VB program to terminate, then reads the data from file and processes it.  Simple stuff.  However, I have a new need... I would like to implement a nice windows progress bar for my script and for that I am guessing that I need PERL to send some kind of message to my Visual Basic Program.  I'm pretty sure that this can be done with the Win32API module.

Can somebody give me some example code of how perl might tell VB to upgrade a progress bar by a certain increment?  What I thought might be possible is for perl to figure out what the increment is (out of 100), to send that information to the VB program, then to send another message every time the progress bar is to be updated by that increment.  I have no idea how to do this.  Any help is very much appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I assume that this is *not* a cgi script.

If the perl program is taking some time to complete, say more than two or three seconds, then the following approach would work.

Every few seconds (there is no need for a more frequent update than about once per second). The perl script writes to a file with a single value, the percentage of the process that is completed, and then closes the file. The VBScript can open and read this file periodically to find out the progress.

If you want to use inter-process communication then this depends upon the operating system (which you did not specify, but I assume is Windows NT). This is more difficult and requires a knowledge of Windows programming, rather than perl programming. If you want to take this approach then you should obtain a module to add to perl that gives access to the API functions. I am sure one exists, I can't remember the name but I will do a search for it for you.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
colindAuthor Commented:
I thought about doing this...  The problem I had was that I wasn't sure what would happen if PERL and VB both tried to open the file at the same time.  Would there be some kind of error?  I guess I would just have to do a test in PERL to make sure that the file was open before trying to write to it.  If I wrote to an unopen file, my progress bar would show something like 80% when the processing was actually at 100%.  How might this affect the VB side?

I knew about the perl module that interfaces with the Win32 API, it is maintained by Aldo Calpini...  It's called Win32::API and can be found at:

I was hoping somebody could show me how to use this to pass a value from PERL to VB and then how to cause an event which the VB program could respond to.

I will try your method though and see how it pans out.

Thank you.
There should be little chance of a conflict. VB is only reading and Perl only writing. If either VB or Perl fail to open the file then at worst there will be a small jump from (say) 80% to 82% missing out 81%. I suspect that any attempt to calculate percentage done (percentage of time?) will always be jumpy anyway. (At least all the ones I have seen so far have been anyway.).

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

colindAuthor Commented:
That's right...  I was thinking of just passing a message to VB saying update the progress bar by the increment...  If instead I say, put the progress bar at 76.8%, then the progress bar would always be right.  

Actually, the way that my program works, the progress bar thing won't be all that jumpy.  It's one huge loop which takes a fairly specific amount of time for each iteration and so time-wise, the progress bar would always be very close.

Do you have any knowledge of how to do implement a progress bar in VB?  Is it difficult?  Let's say I use your idea and perl writes 80.7% to the first line of a file.  How would VB turn that into a progress bar showing 80.7% completion?

Thanks in advance,


I am not familar with VB although I once saw some code written in either C++ or VB, I can't remember. It is something to do with creating a couple of images, one in blue with white text, one in white with blue text (for example) and then displaying the first 80.7% of the blue image and then the final 19.3% of the white image.

I could not comment on the specifics however. The article I saw was on the Microsoft Developers Network CD-ROM's. You might find it if you do a search for progress bars on the Microsoft site.

colindAuthor Commented:
I had another idea. I know that it is quite easy to use OLE through perl using the win32::ole module...  I could just control some property of some object on my VB form and then VB could read from that property and respond.  I think that that will actually turn out to be the easiest and most reliable solution.  Thanks for your help.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.