Solved

Count Up By One, Display Each Update

Posted on 2000-02-25
5
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA: perform index match based on config sheet with two additional parameters. 9 69
TT Auto Dashboard 13 100
Sub or Function is not defined 6 54
backup program with robocopy 6 70
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

763 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