Hack Forums
[.NET] [VB.NET] Use label to count [Add up how many times you've done something] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [VB.NET] Use label to count [Add up how many times you've done something] (/showthread.php?tid=118413)



[VB.NET] Use label to count [Add up how many times you've done something] - BETAhkr - Aug 7, 2009

This will show you how to use a simple label that will count how
many times you do something, such as send a SMS, Or send an E-mail
Or whatever your program is meant to do.

First thing you do is set up how you want your program to work
and add a label and change the text from label1 to the number "0"
I suggest you add another text label in front of that one that
says "Total Times Sent:" Or whatever you would like so it comes
out 2.
Total Times Sent: 0
[IMG]http://i31.[censored].com/343svoi.jpg[/IMG]

Then add this code by its self (Not in another objects directory to place code)
Which ever label# you want to change is the one you need to add. Ex: Label2, Label3, Label4, etc.
Code
Private Counter As Integer = 0
And use this code to add into another sub.
Code
Private Sub SetLabel()
        Me.Label1.Text = Counter.ToString()
    End Sub

[IMG]http://i25.[censored].com/33jn3w3.jpg[/IMG]


Now I'm going to use a timer for this section
This is best used with timers and minute timers.

Declare what you want your timer to do.
Such as send a SMS, or an E-mail
Or whatever you want it to do then add this code.
Code
Counter += 1
        Me.SetLabel()

[IMG]http://i31.[censored].com/a59jc7.jpg[/IMG]

Now you can save, build, And test your program to make sure
you have done everything right and it works fine so far.

[IMG]http://i32.[censored].com/14xdm9x.jpg[/IMG]