Solved

Count Up By One, Display Each Update

Posted on 2000-02-25
5
190 Views
Last Modified: 2010-05-02
Hello,

I need a function with at least on parameter that will cout up by one and at the same time display each update in the label lblCredit in the form frmLuckyOne.  Basically add one to the inputed start, display it, and do it again until the inputed end is met.  Also each update of the label must be visible.

Thank you.
0
Comment
Question by:jc2048
5 Comments
 
LVL 2

Expert Comment

by:mannen
ID: 2558505
Well, I'm not exactly sure what you need, but I think this code does the job (?)... 'DoEvents' makes windows wait for things to happen before it executes the next command (in your case, update the Label).

I'm sure there is a better way, but I think it works...

Just call CountUp(Current) when you want to add 1 to the label.

Dim Current as Long

Private Sub CountUp(ByVal Start as Long)
   Current = Start + 1
   lblCredit.Caption = Current
   DoEvents
End Sub

Vidar Braut Haarr
AmigoSoft Productions
folk@popmail.com
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2558591
Or:

lblCredit.Refresh
0
 
LVL 7

Accepted Solution

by:
Vbmaster earned 50 total points
ID: 2558599
Or the code should probably be something like

  Private Sub CountUp(End As Long)

    Dim a As Long

    For a = (Val(lblCredit.Caption) + 1) To End
      lblCredit.Caption = a
      lblCredit.Refresh          'this one or the one below or both
      DoEvents                     'this one or the one above or both
    Next

  End Sub

I have added both a .Refresh and the DoEvents statement here, you can choose to remove the DoEvents if you do not want the end user to be able to interact with the program during the For..Next loop. This can cause problem if let's say the end user does something that runs the CountUp function again. On the other hand the DoEvents statement will make the program interface to update more smoothly.
0
 

Author Comment

by:jc2048
ID: 2559988
No, I want it update all the credits at once not one at a time.  It would be a real pain to have to call the function 1000 times.
0
 

Author Comment

by:jc2048
ID: 2560008
Well this almost worked without some editing.  But I thank you for the help.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now