Solved

Count Up By One, Display Each Update

Posted on 2000-02-25
5
191 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 103
VB6 Compile Compatibility Issue 4 90
Run code from text file in vb 1 57
How to set the sa password in a vb6 code for sql connection 9 38
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

867 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

15 Experts available now in Live!

Get 1:1 Help Now