You probably need Settings
. Easily Save and Retrieve Application and User Settings in VB.NET or C# Apps. First create ClickCouter
of type integer
with value 0
in settings (see the article).
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
My.Settings.ClickCouter +=1
My.Settings.Save()
If My.Settings.ClickCouter>=10 then Button1.Enabled = False
End Sub
It is necessary to check ClickCouter
also in Form_Load
. The value is stored in a file in a user profile so the solution is not too "hacker proof" (but is fool proof :-D ).