Question

how can i make my application goes to function after certain usage like if i click an button 10 times, then button is disabled just like trial program, so far, i can do that on run-time only, how can i make it count clicks without using Registry? my program is very simple: convert strings to Base64

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    TextBox1.Text = Convert.ToBase64String(New System.Text.ASCIIEncoding().GetBytes(TextBox1.Text))
End Sub
Was it helpful?

Solution

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 ).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top