mdlmain.vb

来自「<Visual Basic 数据库开发实例精粹(第二版)>一书首先介」· VB 代码 · 共 40 行

VB
40
字号
Module Module_Main

  '全局变量,存储已登录的用户信息
  Public LoginedUserInfo As New clientMgrBusiness.UserDataModel
  '是否启用数据库连接助手,版权:http://www.trfsoft.com
  Public IsUseConnSupporter As Boolean = True

  '系统启动函数,需在项目/属性中指定
  Sub main()
    '如果程序已经运行,那么则结束以使该程序只能运行一个实例
    If (UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0) Then
      End
    End If

    '初始化连接字符串
    DBOpProvider.ConnSqlServer.SQLClass.ConnStr = "server=localhost; uid =sa; pwd=; database=clientMgrNet"

    If IsUseConnSupporter Then
      '案例额外加入:测试数据库连接
      Dim strErrMsg As String = ""
      Dim techSupporter As New techSupport.techSupport
      If Not techSupporter.TestConn(DBOpProvider.ConnSqlServer.SQLClass.ConnStr, strErrMsg, Application.ProductName) Then
        MsgBox(strErrMsg, MsgBoxStyle.Exclamation + MsgBoxStyle.SystemModal)
        Application.Exit()
        End
      End If
    End If

    '启动登录与主窗体
    Dim frmLg As New frmLogin
    frmLg.ShowDialog()
    If frmLg.m_bLoginSuccess = True Then
      Dim frmMain As New frmMain
      Application.Run(frmMain)
    End If

  End Sub

End Module

⌨️ 快捷键说明

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