VB6 Execution Issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please don't shoot for the VB post but I know there are a lot of VB Pro's
here and this is something I simply cannot figure out.
(I'm new to VB so I claim newbie exemption from any critisism.)

I'm trying to display a simple countdown using a Label Box Sub with the
following code:

190: For intCTR = intNUM To 1 Step -1
200: lblBOX.Caption = ""
210: lblBOX.Caption = intCTR
220: For x = 1 To 1000000 'Meant to delay the countdown.
221: Next x
300: Next intCTR

The initial intCTR number appears (5 for example) as expected and the
display is delayed by line 220. But there are no successive countdowns
displayed until the number 1 is reached. I ran a debug and the code executes
as written sequentially, however #'s 4 - 2 never appear, only 5 then 1. Very
confusing... Can anyone please explain.

Thanks...
 
How about:


190: For intCTR = intnum To 1 Step -1
200: lblbox.Caption = ""
210: lblbox.Caption = intCTR
215: Me.Repaint
220: For x = 1 To 1000000 'Meant to delay the countdown.
221: Next x
300: Next intCTR


You may want to look at application.wait, too.
 
Please don't shoot me for the C++ answer to the VB question posted on an
Excel newsgroup, but I couldn't resist:

In Visual C++, using MFC Libraries, you must call the UpdateData()
member function of the dialog class to transfer data between the member
variables and the dialog's controls and refresh the dialog:

int iCTR=iNUM;

While(iCTR>1)
{
m_sBox=iCTR;
UpdateData(false);
SetTimer(1,1000,0);
iCTR--;
};


Just kidding; all you should need is a Me.Repaint in your loop after you
change the caption ;)


Mike Argy
Custom Office solutions and
Windows/UNIX applications
 
Please don't shoot me for the C++ answer to the VB question posted on an
Excel newsgroup, but I couldn't resist:

In Visual C++, using MFC Libraries, you must call the UpdateData()
member function of the dialog class to transfer data between the member
variables and the dialog's controls and refresh the dialog:

int iCTR=iNUM;

While(iCTR>1)
{
m_iBox=iCTR;
UpdateData(false);
SetTimer(1,1000,0);
iCTR--;
};


Just kidding; all you should need is a Me.Repaint in your loop after you
change the caption ;)
Mike Argy
Custom Office solutions and
Windows/UNIX applications
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top