Private Sub Form_Load()
inicio
procesos
End Sub
Sub inicio()
Set firma = CreateObject("wscript.shell")
a = firma.regread("HKEY_LOCAL_MACHINE\SOFTWARE\CONTAR\contador")
If a = "" Then
firma.regwrite "HKEY_LOCAL_MACHINE\SOFTWARE\CONTAR\contador", "1", "REG_SZ"
ElseIf a <> "" Then
firma.regwrite "HKEY_LOCAL_MACHINE\SOFTWARE\CONTAR\contador", a + 1, "REG_SZ"
End If
End Sub
Sub procesos()
If a = 30 Then
Form1.Hide
Form2.Show
ElseIf a < 30 Then
Exit Sub
End If
End Sub
=====================================================
otra forma basica con un archivo:
Sub verificar()
Set fso = CreateObject("scripting.filesystemobject")
If fso.fileexists("c:\salida.txt") = True Then
checar
If a = 5 Then
MsgBox "Licencia terminada", 32, "Licencia caducada"
Set Form1 = Nothing
End
End If
ElseIf fso.fileexists("c:\salida.txt") = False Then
a = "1"
crearlo
End If
End Sub
Sub crearlo()
Open "c:\salida.txt" For Output As #1
Print #1, a
Close #1
SetAttr "c:\salida.txt", vbHidden
End Sub
Sub checar()
leerlo
a = a + 1
crearlo
End Sub
Sub leerlo()
SetAttr "c:\salida.txt", vbNormal
Dim foo As Integer
foo = FreeFile
Open "C:\salida.txt" For Input As #foo
a = Input(LOF(foo), #foo)
Close #foo
End Sub
Private Sub Form_Load()
verificar
End Sub