Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Count Up By One, Display Each Update

Posted on 2000-02-25
5
Medium Priority
?
199 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 100 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

972 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