Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27479

How to reset static counter

$
0
0
Hello everyone,

I am using Visual Basic Community 2022. I have one button and one textbox, eventually there will be more buttons and textboxes. Anyway, I have the following code for my button:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Static count As Integer
count = count + 1
TextBox1.Text = count
End Sub

I want the button clicks to be counted in the textbox. I have also created a reset button. Now, my problem is when I click on reset the textbox shows 0 but when I click the counter button again, the count continues from where it left off. What I want is for the count to reset back to 0. Could someone please tell me what to do. I am new to coding and not sure what to do. Thank you.

Viewing all articles
Browse latest Browse all 27479

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>