Make a function happen ONLY ONCE on startup of Program {RESOLVED}
Hello,
I need to know how I could make my program have a welcome message ONLY the first time the porgram starts?
Thank you for your help everyone!
Stilekid007
____________________________
I RATE ALL HELPFULL POSTS! :thumb:
Re: Make a function happen ONLY ONCE on startup of Program
Well there are a lot of ways to do it but here's one. Create a global variable called bDone and then do
VB Code:
Public Sub DisplayWelcome()
If bDone Then Exit Sub
' Welcome message
bDone = True
End Sub
Re: Make a function happen ONLY ONCE on startup of Program
Hi, u could use some api too save data in the windows registry. U could save something like "INIT_FLAG = True". When the program start u check that value and procede as needed
If i recall correctly those api are:
GetPrivateProfileString
WritePrivateProfileString
I know i'm not being very clear but is not very easy for me to write in english, i hope i could give a clue.
bye!
Re: Make a function happen ONLY ONCE on startup of Program
Or for simplicity... GetSetting & SaveSetting will also read & save to the registry.
Tg
Re: Make a function happen ONLY ONCE on startup of Program
Strange, it seems very easy to do it unless what you are talking about is to display a welcome message only after running your app for the first time when it was installed then in the succeeding time you will run your program the welcome message will not appear anymore.
Re: Make a function happen ONLY ONCE on startup of Program
Hello everyone! Thank you for your replys! Martin - Your code works nice for the way it was meant but what I meant (I didn't explain very well) is how DEE-U explained it.
I need my program to
Quote:
Display a welcome message only after running your app for the first time when it was installed then in the succeeding time you will run your program the welcome message will not appear anymore
Can this even be done?
Thank you to everyone!
Stilekid007 :wave:
Re: Make a function happen ONLY ONCE on startup of Program
Then you should use techgnome's suggestion. You can look at the Use SaveSetting and GetSetting to store and retrieve data from the Registry link in my signature for an example. The example (if I remember correctly) saves the value of a textbox but you could modify it to just say "did it once already" or something like that.
Re: Make a function happen ONLY ONCE on startup of Program
Ok, here is some code I setup.
It makes my program display the message only the first time the proram runs after installation.
I have a text box (INVISIBLE) and the code below.
VB Code:
Private Sub Form_Load()
Text3.Text = GetSetting(App.EXEName, "Settings", "Username")
If Text3.Text = "PRELOADED" Then
'Do Nothing
Else
' Display Welcome Msg
SaveSetting App.EXEName, "Settings", "Username", "PRELOADED"
End If
End Sub
Thank you all and have a great day! :thumb:
Stilekid007 :wave:
Re: Make a function happen ONLY ONCE on startup of Program
You don't need the textbox.
VB Code:
Private Sub Form_Load()
Dim strLoaded As String
strLoaded = GetSetting(App.EXEName, "Settings", "Username")
If strLoaded = "PRELOADED" Then
'Do Nothing
Else
' Display Welcome Msg
SaveSetting App.EXEName, "Settings", "Username", "PRELOADED"
End If
End Sub
Re: Make a function happen ONLY ONCE on startup of Program {RESOLVED}
Hmmm... Thats nice! thank you sir! :thumb: :wave:
Have a great day!
Stilekid007