比较傻的文件方式
Dim n
If Dir("c:/1") <> "" Then
Open "c:/1" For Input As #1
Input #1, n
Close #1
If Val(n) <= 10 Then
n = Val(n) + 1
Else
MsgBox "已过期"
End
End If
Kill "c:/1"
Open "c:/1" For Output As #1
Print #1, n
Close #1
Else
Open "c:/1" For Output As #1
Print #1, 1
Close #1
End If
一般的注册表方式
Dim Times As Integer '已经使用的次数
'使用次数限制(5次)
Times = GetSetting(App.EXEName, "time", "times", 1)
'提示
If Times < 30 Then
MsgBox "仅剩下" & Str$(30 - Times) & "次可以使用!", vbInformation, "试用版"
Times = Times + 1
SaveSetting AppName:=App.EXEName, section:="time", Key:="times", setting:=Str(Times)
Me.Hide
Load mainfrm
mainfrm.Show
Else
MsgBox "软件试用期已满,请尽快向软件开发商申请正式使用许可!", vbInformation, "试用版"
End
End If