Post by Gaurav Mall on Jul 19, 2016 21:42:19 GMT 10
Hey I wanted to know how to run a method only once in the Application's Lifetime.Can Anyone help me? I tried using the My.Settings Function in VB.What i did was this :
If My.Settings.FirstTime = True Then MsgBox("Welcome to this app for the first time!!!") My.Settings.FirstTime = False Else
End If
Gaurav ---------- Mall
|
|
Post by altair on Jul 20, 2016 3:04:37 GMT 10
These stuff are a bit tough to debug, as My.Settings store a variable into the system... If it is already set to false in the current system... Even when debugging... It will return false. Use My.Settings.Reset() for now when you want old data to be deleted.... My Suggestion Try using Text Configuration files instead of My.Settings for these purposes... As it will be difficult to debug in the future.. P.SPlease make your question a bit more clear.. It is very difficult to understand what you are saying...
Last Edit: Jul 20, 2016 3:10:35 GMT 10 by altair
|
|
Post by Nathan Lecompte on Jul 20, 2016 8:29:22 GMT 10
Just make a Boolean called first "first-time" and set its default value to true, then in your forms load event set it to false (however you'd have to comment it out whilst debugging)
|
|
Post by Nathan Lecompte on Jul 20, 2016 8:29:59 GMT 10
You just need to make sure you save the my.settings before closure
|
|
Post by Gaurav Mall on Jul 20, 2016 22:55:11 GMT 10
That is what I was using Nathan.But after a problem my application can't run properly.I tried using a file but it didn't work.Then I came here and see your replies.What i did is this :
If Not File.Exists(AppDomain.CurrentDomain.BaseDirectory & "File.txt") Then MsgBox("Welcome to Media Player for First Time!) Dim save As New System.IO.StreamWriter(AppDomain.CurrentDomain.BaseDirectory & "\Files\" & name & extension) save.Write("Launched App for first time!") save.Close() End If
But anyways thanks for replying.
Gaurav ---------- Mall
|
|
Post by Gaurav Mall on Jul 20, 2016 22:55:55 GMT 10
That is what I was using Nathan.But after a problem my application can't run properly.I tried using a file but it didn't work.Then I came here and see your replies.What i did is this :
If Not File.Exists(AppDomain.CurrentDomain.BaseDirectory & "File.txt") Then MsgBox("Welcome to Media Player for First Time!) Dim save As New System.IO.StreamWriter(AppDomain.CurrentDomain.BaseDirectory & "\Files\" & name & extension) save.Write("Launched App for first time!") save.Close() End If
But anyways thanks for replying.
Gaurav ---------- Mall
|
|