?
Solved

Count Up By One, Display Each Update

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

Technology Partners: 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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

719 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