How do I know the first time a program runs??

Blaaboy
06-26-2003, 06:41 AM
Hi,

I am using SaveSetting and GetSetting in my VB code. The trouble is, the first time the program runs, no setting has been saved and I get a runtime error! How can I find out the first time the program is run so as I can use a default value for SaveSetting??

Thanks,

Blaaboy

OnErr0r
06-26-2003, 06:49 AM
Use the last argument of GetSetting, it is for a default value.

blindwig
06-26-2003, 08:43 PM
yeah, what OnErr0r said. The code might look like this:

function IsFirstTimeRun as boolean
dim sRetVal as string
IsFirstTimeRun=GetSetting(App.Title, "Settings", "RunBefore", chr(0))=chr(0)
SaveSetting App.Title, "Settings", "RunBefore", "1"
end function

FuRiOuS1
06-30-2003, 02:25 AM
On Error GoTo RegErr
Text1.text = GetSetting("FORM1", "Settings", "TEXT")
RegErr:
If Err.Number <> "13" Or "0" Then Resume Next


if the program cant get the setting from the registry because it's not there, it will give you error 13, and/or 0 (i dont remember which one, i just always put it like that), this will supress that error and contine the program

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum