reg code question

Discussion in 'Questions (Windows Mobile)' started by scott93727, May 30, 2008.

  1. scott93727

    scott93727 Member Licensed User

    any idea why I getting an error on this code and how to complete it, thanks !!!

    Sub Globals
    'Declare the global variables here.
    regdt=Date(Now)
    rc=0
    End Sub
    Sub App_Start
    Form1.Show
    reg
    End Sub
    Sub reg
    Dim regexp
    ErrorLabel(Err1)
    If FileExist ("c:\windows\clrbn.txt") = true Then
    FileOpen (c1,"c:\windows\clrbn.txt",cRead)
    r = FileRead (c1)
    FileClose (c1)
    Else
    regdt=Date(Now)
    FileOpen (c1,"c:\windows\clrbn.txt",cWrite)
    FileWrite (c1,regdt)
    FileClose (c1)
    End If
    textbox1.Text=r ' Displays Registration Date
    textbox3.text=Date(Now) ' Displays Today Date
    rd=DateAdd(r, 0, 1, 0)'sets reg duration (Ticks, Years, Months, Days)for one month
    textbox2.text=rd ' Displays Registration Expires Date
    dn=Date(Now)
    If dn > rd Msgbox("Registration Expired, Contact Support for Registered Version, Contact scott93727@aol.com"):rc=1 ' if date now later then regdate by 1 month
    Goto sed
    err1:
    Msgbox("Registration Error, Contact Support, scott93727@aol.com")
    sed:
    'if rc=1 then (Control code (what to disable after reg. expires))
    End Sub
     
  2. agraham

    agraham Expert Licensed User

    You are missing a "Then" in the "IF dn > rd" statement on line 28. Also the statement "rc=1" on the same line will not execute (but the compiler won't error it) as a single line IF only executes one statement. I would strongly advise against ever using a single line IF statement. I always use IF ... End If as I think it makes things much clearer and avoids bugs.
     
  3. scott93727

    scott93727 Member Licensed User

    figured it out, wil be uploading registration form soon.

    Sub reg ' complete registration manager in one sub
    regdt=Date(Now)
    ErrorLabel(Err1)
    If FileExist ("c:\windows\clrbn.txt") = true Then 'opens registration file information
    FileOpen (c1,"c:\windows\clrbn.txt",cRead)
    r = FileRead (c1)
    FileClose (c1)
    Else
    regdt=Date(Now)
    FileOpen (c1,"c:\windows\clrbn.txt",cWrite) 'creates registration file information
    FileWrite (c1,regdt)
    FileClose (c1)
    End If
    textbox1.Text=r ' Displays Registration Date
    textbox3.text=Date(Now) ' Displays Today Date
    x = DateParse (r) ' converts install date to ticks
    rd=DateAdd(x, 0, 1, 0)'sets reg duration in ticks (Ticks, Years, Months, Days)for one month
    textbox2.text=Date(rd) ' converts ticks to date and Displays Registration Expires Date
    td=Now ' todays date in ticks
    textbox4.text=rd 'displays regticks
    textbox5.text=rd 'dis[lays expticks
    textbox6.text=td 'displays todayticks
    If rd < td Then Msgbox("Registration Expired, Contact Support for Registered Version, Contact scott93727@aol.com")' if date now later then regdate by 1 month
    If rd < td Then Goto regctl Else Goto regend
    Goto regend
    err1:
    Msgbox("Registration Error, Contact Support, scott93727@aol.com")
    regctl:
    Form1.Text = "Registration expired, Contact Support"
    textbox7.Text="Registration expired...Contact Support at scott93727@aol.com"
    'rc=1 (Declare global rc=0) for Control code (what to disable after reg. expires))
    ' example if rc = 1 then close form1
    Goto rged
    regend:
    Form1.Text = "Registration Period Active..."
    textbox7.Text=" Registration Period Active..."
    rged:
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice