|
-
Jun 29th, 2005, 08:25 PM
#1
Thread Starter
Hyperactive Member
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!
Last edited by stilekid007; Jun 30th, 2005 at 09:50 AM.
-
Jun 29th, 2005, 08:36 PM
#2
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
-
Jun 29th, 2005, 08:36 PM
#3
Member
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!
Last edited by Matias; Jul 21st, 2005 at 09:22 AM.
-
Jun 29th, 2005, 08:38 PM
#4
Re: Make a function happen ONLY ONCE on startup of Program
Or for simplicity... GetSetting & SaveSetting will also read & save to the registry.
Tg
-
Jun 29th, 2005, 08:38 PM
#5
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.
-
Jun 29th, 2005, 09:26 PM
#6
Thread Starter
Hyperactive Member
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
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
 Originally Posted by stilekid007
-
Jun 29th, 2005, 09:46 PM
#7
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.
-
Jun 30th, 2005, 09:43 AM
#8
Thread Starter
Hyperactive Member
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! 
Stilekid007
 Originally Posted by stilekid007
-
Jun 30th, 2005, 09:50 AM
#9
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
-
Jun 30th, 2005, 09:52 AM
#10
Thread Starter
Hyperactive Member
Re: Make a function happen ONLY ONCE on startup of Program {RESOLVED}
Hmmm... Thats nice! thank you sir! 
Have a great day!
Stilekid007
 Originally Posted by stilekid007
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|