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

📄 mdl_comvarlist.bas

📁 图书馆信息管理系统
💻 BAS
字号:
Attribute VB_Name = "Mdl_ComVarList"
Public AppPath As String                   '程序路径
Public AppVersion As String                '程序版本号

Public strUID As String                    '登录用户
Public strLastLogTime As String            '用户上次登录时间
Public strSQLServer As String              'SQL Server服务器
Public strSQLUID As String                 'SQL Server用户名
Public strSQLPassword As String            'SQL Server密码
Public strSQLDB As String                  'SQL Server数据库

Public LastForm As Form                    '储存主窗口中之前所打开的子窗口

Option Explicit

'自定义消息框函数
Public Function MsgFrm(MsgTxt As String, Optional MsgType As String, Optional FrmTitle As String) As Integer
On Error GoTo ERRORZONE
    Dim NewMsg As New Frm_MsgFrm
    Dim F_W As Long      '储存窗体宽
    Dim F_H As Long      '储存窗体高
    Dim Space As Long    '控件间距
    Space = 240

    With NewMsg
        '如果没有“标题”参数则使用应用程序的标题
        .caption = IIf(FrmTitle = vbNullString, App.Title, FrmTitle)
        
        '将“消息”参数赋值给窗体的标签
        .Lbl_Message.caption = MsgTxt
        
        '窗口大小随文本标签大小而变化(超过默认值后)
        If .Lbl_Message.Width > 3240 Then    '18个8号汉字长度
            .Width = .Lbl_Message.Left + .Lbl_Message.Width + 90 + Space
        End If
        If .Lbl_Message.Height > 585 Then    '3行8号汉字高度
            .Height = .Lbl_Message.Top + .Lbl_Message.Height + 480 + Space + .Cmd_OK.Height + Space
        End If
        
        F_W = .Width
        F_H = .Height
        
        '根据“窗体类型”参数决定显示的图片和按钮位置
        If MsgType = "?" Then
        '疑问消息框
            .Pic_TBarSymbol.Picture = LoadPicture(AppPath & "Images\Picture\MsgBox_Question.ico")
            .Cmd_OK.Visible = True        '“确定”按钮可见
            .Cmd_Cancel.Visible = True    '“取消”按钮可见
            .Cmd_OK.Left = 45 + 960 + (F_W - 90 - 960) / 2 - .Cmd_OK.Width - 120
            .Cmd_Cancel.Left = 45 + 960 + (F_W - 90 - 960) / 2 + 120
            .Cmd_OK.Top = F_H - 480 - .Cmd_OK.Height - Space
            .Cmd_Cancel.Top = F_H - 480 - .Cmd_OK.Height - Space
        ElseIf MsgType = "x" Then
        '错误消息框
            .Pic_TBarSymbol.Picture = LoadPicture(AppPath & "Images\Picture\MsgBox_Error.ico")
            .Cmd_OK.Visible = True         '“确定”按钮可见
            .Cmd_Cancel.Visible = False    '“取消”按钮隐藏
            .Cmd_OK.Left = 45 + 960 + (F_W - 90 - 960) / 2 - .Cmd_OK.Width / 2
            .Cmd_OK.Top = F_H - 480 - .Cmd_OK.Height - Space
        Else
        '提示消息框及其它类型
            .Pic_TBarSymbol.Picture = LoadPicture(AppPath & "Images\Picture\MsgBox_Caution.ico")
            .Cmd_OK.Visible = True         '“确定”按钮可见
            .Cmd_Cancel.Visible = False    '“取消”按钮隐藏
            .Cmd_OK.Left = 45 + 960 + (F_W - 90 - 960) / 2 - .Cmd_OK.Width / 2
            .Cmd_OK.Top = F_H - 480 - .Cmd_OK.Height - Space
        End If
        
        .Show 1    '显示自定义的消息窗体
        
        '根据窗体关闭时所按的按钮来确定函数的返回值
        If .ReturnValue = 1 Then
        '“确定”返回1
            MsgFrm = 1
        ElseIf .ReturnValue = 2 Then
        '“取消”返回2
            MsgFrm = 2
        End If
    End With
    Exit Function
    
ERRORZONE:
    MsgFrm = -1    '“错误”返回-1
End Function

'将提示信息显示到主窗口的状态栏
Public Sub ShowTip(Optional strTip As String)
    With Frm_Main
        If strTip = vbNullString Then
            .Pic_SBarTip.Visible = False
            .Lbl_SBarTip.caption = vbNullString
            .Lbl_SBarTip.Left = .Pic_SBarTipBack.Width
        Else
            .Pic_SBarTip.Visible = True
            .Lbl_SBarTip.ForeColor = RGB(255, 0, 0)
            .Lbl_SBarTip.caption = Trim(strTip)
            .Lbl_SBarTip.Left = .Pic_SBarTipBack.Width
            .Timer_Tip.Enabled = True
        End If
    End With
End Sub

⌨️ 快捷键说明

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