⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module1.bas

📁 称重管理软件(大型地磅)源码 为农贸市场定制开发
💻 BAS
字号:
Attribute VB_Name = "Module1"

Sub Main()
On Error GoTo Error
''系统检测是否有date.mdb文件,如果没有,则是系统第一次启动,则建立之
If Dir("c:\windows\system\yy.bak") = "" Then

''注意在开始,您要确定您的工程引用了Microsoft dao 2.5/3.5 compatibility library 在"工程"==>"引用"中.

Dim WS As Workspace
Dim DB As Database
Dim TD As TableDef
Dim fldd As Field
Dim IDX As Index
Dim rd As Recordset
Set WS = DBEngine.Workspaces(0)
Set DB = WS.CreateDatabase("c:\windows\system\yy.bak", dbLangGeneral)
DB.Connect = ";pwd=andy"
Set TD = DB.CreateTableDef("date")
TD.Attributes = 0
TD.Connect = ""
TD.SourceTableName = ""
TD.ValidationRule = ""
TD.ValidationText = ""
'' Field first_time
Set fldd = TD.CreateField("first_time", 8, 8)
fldd.Attributes = 1
fldd.DefaultValue = ""
fldd.OrdinalPosition = 0
fldd.Required = False
fldd.ValidationRule = ""
fldd.ValidationText = ""
TD.Fields.Append fldd
'' Field last_time
Set fldd = TD.CreateField("last_time", 8, 8)
fldd.Attributes = 1
fldd.DefaultValue = ""
fldd.OrdinalPosition = 1
fldd.Required = False
fldd.ValidationRule = ""
fldd.ValidationText = ""
TD.Fields.Append fldd
'' Field times
Set fldd = TD.CreateField("times", 3, 2)
fldd.Attributes = 1
fldd.DefaultValue = ""
fldd.OrdinalPosition = 2
fldd.Required = False
fldd.ValidationRule = ""
fldd.ValidationText = ""
TD.Fields.Append fldd
DB.TableDefs.Append TD
DB.Close
Set DB = WS.OpenDatabase("c:\windows\system\yy.bak")
Set rd = DB.OpenRecordset("date")
With rd
.AddNew
.Fields("first_time") = Date
.Fields("last_time") = Date
.Fields("times") = 1
.Update
End With

DB.Close
'MsgBox "这是您第一次启动本系统!您的试用期为30天,今天是第一天.谢谢使用!", 48, "安徽皖方软件科技有限公司"

''效果如图1 (见附件1)

enter.Show ''启动您的主窗体



Else ''系统有date.mdb文件,则不是第一次运行,就不用建立数据库文件了.

Dim WS2 As Workspace
Dim DB2 As Database
Dim rd2 As Recordset
Set WS2 = Workspaces(0)
Set DB2 = WS2.OpenDatabase("c:\windows\system\yy.bak", pwd = "springlover")
Set rd2 = DB2.OpenRecordset("date")
''开始检测用户是否修改了系统日期
rd2.MoveFirst
If rd2.Fields("last_time") > Date Then
MsgBox "对不起,您在本软件的试用期内不可以修改系统日期,否则将取消您对本系统的试用权.如果您想继续使用本软件,请您恢复系统日期.谢谢合作!", 48, "安徽皖方软件科技有限公司"



End
End If

''开始检测是否超期

If Date - rd2.Fields("first_time") >= 60 Then ''设定试用期为30天
MsgBox "您已经启动本系统" & rd2.Fields("times") & "次了,而且已经到了60天的试用期,如果您想继续使用本软件,请您到本公司注册并购买正版的软件! Tel:0551-2884899  QQ:11624317", 48, "安徽皖方软件科技有限公司"



End

Else

''仍在试用期内
num% = rd2.Fields("times")
rd2.Edit
rd2.Fields("last_time") = Date
rd2.Fields("times") = num + 1
rd2.Update

'MsgBox "这是您第" & rd2.Fields("times") & "次使用本系统,您还有" & 30 - (Date - rd2.Fields("first_time")) & "天的试用期,祝您今天工作愉快!", 48, "安徽皖方软件科技有限公司"

''效果如图2 (见附件2)

enter.Show ''启动您的主窗体


End If





End If
Exit Sub
Error:
MsgBox "系统错误!"

End Sub


Function GetIni(strPrimary, strSubKey, strIniFilePath)
Dim myFso
Dim MyFile
Dim intCount, strState
Set myFso = CreateObject("Scripting.FileSystemObject")

Set MyFile = myFso.OpenTextFile(strIniFilePath, 1, False, False)
With MyFile
Do Until .AtEndOfStream
If intCount = 0 Then
If .ReadLine = "[" & strPrimary & "]" Then
intCount = 1
End If
Else
strState = .ReadLine
If UCase(Left(strState, Len(strSubKey & "="))) = UCase(strSubKey & "=") Then
GetIni = Right(strState, Len(strState) - Len(strSubKey & "="))
End If
End If
Loop
.Close
End With
Set MyFile = Nothing
Set myFso = Nothing
End Function

Function cipher(stext As String)    '加密程序
    Const min_asc = 32
    Const max_asc = 126
    Const num_asc = max_asc - min_asc + 1
    Dim offset As Long
    Dim strlen As Integer
    Dim i As Integer
    Dim ch As Integer
    offset = 123
    Rnd (-1)
    Randomize (offset)
    strlen = Len(stext)
    For i = 1 To strlen
       ch = Asc(Mid(stext, i, 1))
       If ch >= min_asc And ch <= max_asc Then
           ch = ch - min_asc
           offset = Int((num_asc + 1) * Rnd())
           ch = ((ch + offset) Mod num_asc)
           ch = ch + min_asc
           ptext = ptext & Chr(ch)
       End If
    Next i
    cipher = ptext
End Function

Function decipher(stext As String)      '解密程序
    Const min_asc = 32
    Const max_asc = 126
    Const num_asc = max_asc - min_asc + 1
    Dim offset As Long
    Dim strlen As Integer
    Dim i As Integer
    Dim ch As Integer
    offset = 123
    Rnd (-1)
    Randomize (offset)
    strlen = Len(stext)
    For i = 1 To strlen
       ch = Asc(Mid(stext, i, 1))
       If ch >= min_asc And ch <= max_asc Then
           ch = ch - min_asc
           offset = Int((num_asc + 1) * Rnd())
           ch = ((ch - offset) Mod num_asc)
           If ch < 0 Then
               ch = ch + num_asc
           End If
           ch = ch + min_asc
           ptext = ptext & Chr(ch)
       End If
    Next i
    decipher = ptext
End Function
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -