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

📄 modpublic.bas

📁 一款非常适合中小学教学任务不是很繁重的管理程序
💻 BAS
字号:
Attribute VB_Name = "modPublic"
Public strUserName As String       '用户名
Public strPower As String          '权限
Public bForever As Boolean         '永久保存
Public dtYear As String            '输入的年份
Public iC As Integer               '打印全局量
'检测文本框中数据是否为数字
Public Function checkTextBox(txt As TextBox, strName As String) As Boolean
checkTextBox = False
If Trim(txt.Text) = "" Then
    MsgBox strName & "内容不能为空!", vbOKOnly + vbCritical, "学生教务管理系统"
    txt.SetFocus
Else
    If Not IsNumeric(Trim(txt.Text)) Then
        MsgBox strName & "中要填入数字!", vbOKOnly + vbCritical, "学生教务管理系统"
        txt.Text = ""
        txt.SetFocus
    Else
        checkTextBox = True
    End If
End If
End Function
'检测下拉列表中数据是否为空
Public Function checkCombolBox(txt As ComboBox, strName As String) As Boolean
checkCombolBox = False
If Trim(txt.Text) = "" Then
    MsgBox strName & "内容不能为空!", vbOKOnly + vbCritical, "学生教务管理系统"
    txt.SetFocus
Else
    checkCombolBox = True
End If
End Function
'生成非永久编号
Public Function nonForeverNum() As Integer
    Dim strSql, str1, str2, str3, str4 As String
    Dim i1, i2, i3, i4, iMax As Integer
    strSql = "select max(recordId) as maxId from tabCredence where yearS=" & dtYear & " and timeS<>'永久'"
    str1 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabBook where yearS=" & dtYear & " and timeS<>'永久'"
    str2 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabReport where yearS=" & dtYear & " and timeS<>'永久'"
    str3 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabOther where yearS=" & dtYear & " and timeS<>'永久'"
    str4 = dbSelectOnly(strSql)
    
    i1 = Val(Trim(str1))
    i2 = Val(Trim(str2))
    i3 = Val(Trim(str3))
    i4 = Val(Trim(str4))
    
    iMax = i1
    If i2 > iMax Then iMax = i2
    If i3 > iMax Then iMax = i3
    If i4 > iMax Then iMax = i4
    
    nonForeverNum = iMax + 1
End Function
'生成永久编号
Public Function ForeverNum() As Integer
    Dim strSql, str1, str2, str3, str4 As String
    Dim i1, i2, i3, i4, iMax As Integer
    strSql = "select max(recordId) as maxId from tabCredence where timeS='永久'"
    str1 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabBook where timeS='永久'"
    str2 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabReport where timeS='永久'"
    str3 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabOther where timeS='永久'"
    str4 = dbSelectOnly(strSql)
    
    i1 = Val(Trim(str1))
    i2 = Val(Trim(str2))
    i3 = Val(Trim(str3))
    i4 = Val(Trim(str4))
    
    iMax = i1
    If i2 > iMax Then iMax = i2
    If i3 > iMax Then iMax = i3
    If i4 > iMax Then iMax = i4
    
    ForeverNum = iMax + 1
End Function

'验证非永久编号 重复返回”假“
Public Function checkNonForeverNum(ByVal iYear As String, ByVal iNum As String) As Boolean
checkNonForeverNum = False
iNum = Trim(str(Val(iNum)))
    Dim strSql, str1, str2, str3, str4 As String
    Dim i1, i2, i3, i4, iMax As Integer
    strSql = "select count(*) from tabCredence where yearS=" & iYear & " and timeS<>'永久' and recordId=" & iNum
    str1 = dbSelectOnly(strSql)
    strSql = "select count(*) from tabBook where yearS=" & iYear & " and timeS<>'永久' and recordId=" & iNum
    str2 = dbSelectOnly(strSql)
    strSql = "select count(*) from tabReport where yearS=" & iYear & " and timeS<>'永久' and recordId=" & iNum
    str3 = dbSelectOnly(strSql)
    strSql = "select count(*) from tabOther where yearS=" & iYear & " and timeS<>'永久' and recordId=" & iNum
    str4 = dbSelectOnly(strSql)
    
    i1 = Val(Trim(str1))
    i2 = Val(Trim(str2))
    i3 = Val(Trim(str3))
    i4 = Val(Trim(str4))
    
    If i1 > 0 Then checkNonForeverNum = True
    If i2 > 0 Then checkNonForeverNum = True
    If i3 > 0 Then checkNonForeverNum = True
    If i4 > 0 Then checkNonForeverNum = True
    
End Function
'验证永久编号 重复返回”假“
Public Function checkForeverNum(ByVal iNum As String) As Boolean
checkForeverNum = False
iNum = Trim(str(Val(iNum)))
    Dim strSql, str1, str2, str3, str4 As String
    Dim i1, i2, i3, i4, iMax As Integer
    strSql = "select max(recordId) as maxId from tabCredence where timeS='永久' and recordId=" & iNum
    str1 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabBook where timeS='永久' and recordId=" & iNum
    str2 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabReport where timeS='永久' and recordId=" & iNum
    str3 = dbSelectOnly(strSql)
    strSql = "select max(recordId) as maxId from tabOther where timeS='永久' and recordId=" & iNum
    str4 = dbSelectOnly(strSql)
    
    i1 = Val(Trim(str1))
    i2 = Val(Trim(str2))
    i3 = Val(Trim(str3))
    i4 = Val(Trim(str4))
    
    If i1 > 0 Then checkForeverNum = True
    If i2 > 0 Then checkForeverNum = True
    If i3 > 0 Then checkForeverNum = True
    If i4 > 0 Then checkForeverNum = True
End Function
'将数字编号转换为三位字符
Public Function convertToString(i As Integer) As String
If i < 10 Then convertToString = "00" & Trim(str(i))
If i < 100 And i >= 10 Then convertToString = "0" & Trim(str(i))
If i < 1000 And i >= 100 Then convertToString = Trim(str(i))
End Function


'计算闰年,是闰年返回真,不是返回假
Public Function yearsSp(iYear As Integer) As Boolean
If (iYear Mod 100) = 0 Then
    If (iYear Mod 400) = 0 Then
        yearsSp = True
    Else
        yearsSp = False
    End If
Else
    If (iYear Mod 4) = 0 Then
        yearsSp = True
    Else
        yearsSp = False
    End If
End If
End Function


⌨️ 快捷键说明

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