In this basic Tutorial I will be showing all of you how to make an item, could be a Alert, or could be a any event you want only show once. In this tutorial, ill be showing you how to do it for a Message Box on Load.
Ill go slow for the beginners.
Step 1
You should make a New Project, or use an existing project.
Now, go to the Solution Explorer on the right, and double click on My Project.
Step 2
Go to Settings and add a new setting called "OneTime". should look like this
Step 3
Go back to Form1, and click its form, so you can be in the Form1 Class.
Right below
add
Code:
Dim Settings As New My.MySettings
So it looks like
Code:
Public Class Form1
Dim Settings As New My.MySettings
Step 4
Go into Form1 Load sub, if you dont know what that is, it looks like
Code:
Private Sub Form1_Load......
Under that, add this
Code:
If Settings.OneTime = "1" Then
Press Enter, and an "End If" should appear below it.
What this does is it gives us a If statement, so that we can make it so If Settings.oneTime does equal to 1, then it will do nothing, and if it doesnt equal to 1, then it will show a messagebox.
If all went well, it should be looking like this
Step 4B
Between the above code, and the End If put
Code:
Else
MsgBox("Thank you for downloading this Tutorial App, This will only show Once", , "Thank You!")
So it should look like
I hope im going slow enough for you.
Step 4C
Last part of the code, We are now going to make the Settings of OneTIme (Settings.OneTime) equal 1, so that it will not show up again.
Below the code we talked about in Step 4B, add this
Code:
Settings.OneTime = "1"
Settings.Save()
So now after everything it should look like
Debug
Now Press the Debug button on the top, and you should get a PopUp, opening it up again will make it not show.
When you have your finished .EXE please do not open it and give it out, or that saved setting will go with it, instead make a copy of the exe, and then click the copy, releasing the original to the public.
Complete Code
Code:
Public Class Form1
Dim Settings As New My.MySettings
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Settings.OneTime = "1" Then
Else
MsgBox("Thank you for downloading this Tutorial App, This will only show Once", , "Thank You!")
Settings.OneTime = "1"
Settings.Save()
End If
End Sub
End Class