Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,933 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,742 people online right now. Registration is fast and FREE... Join Now!




counter with numbers

 
Reply to this topicStart new topic

counter with numbers

devilsangeleyes
16 Dec, 2007 - 06:30 AM
Post #1

New D.I.C Head
*

Joined: 24 Feb, 2006
Posts: 17


My Contributions
Can someone help me?

I'm trying to write code for a counter from zero to 1000. But there are some things I can't find:
- When I click start it only shows 0 and 1000. How can I make that I can see all the numbers (0, 1, 2, 3, ..., 999,1000)?
- How can I make it stop when I click the stop button? And that it goes further if I click the start button again?

This is what I got and that works:
CODE

Public Class FrmCounter

    
    Private Sub BtnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnStart.Click
        Dim counter As Integer = 0

        While (counter < 1000)
            counter = counter + 1
            LblCounter.Text = counter
        End While
    End Sub

    Private Sub BtnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnReset.Click
        'Put counter back to zero
        LblCounter.Text = "0"
    End Sub

    Private Sub BtnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnStop.Click

    End Sub
End Class

User is offlineProfile CardPM
+Quote Post

ferrari12508
RE: Counter With Numbers
16 Dec, 2007 - 08:45 AM
Post #2

D.I.C Lover
Group Icon

Joined: 2 Nov, 2007
Posts: 1,112



Thanked: 2 times
Dream Kudos: 150
My Contributions
It goes from 0 to 1000 so fast that you cannot see it, add a timer to it and set the loop to process once a second or something. If you want to make it display all of the numbers try
CODE

lblCounter.text = lblcounter.text & " " & counter


Also, for your reset button add the code
CODE

counter = 0



This post has been edited by ferrari12508: 16 Dec, 2007 - 08:47 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 03:25PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month