start.bas

来自「商品进销存软件」· BAS 代码 · 共 46 行

BAS
46
字号
Attribute VB_Name = "Start"
Option Explicit

Public ConnStr As String
Public gintDHmode As Integer
Public Sub Main()
  If App.PrevInstance = True Then
    MsgBox "程序已经运行!", vbOKOnly + vbInformation, "系统提示"
    End
  End If
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data\info.mdb;Persist Security Info=False"
Load frmlogo
frmlogo.Show
End Sub

Public Function ExeSQL(ByVal sql As String) As ADODB.Recordset
 On Error GoTo ErrInfo:
    
    Dim Conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim strArray() As String
    
    Set Conn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    
    strArray = Split(sql)
    Conn.Open ConnStr
    
    If StrComp(UCase$(strArray(0)), "select", vbTextCompare) = 0 Then
           rs.Open Trim$(sql), Conn, adOpenKeyset, adLockOptimistic
        Set ExeSQL = rs
    Else
        Conn.Execute sql
    End If

ExeSQl_Exit:
    Set rs = Nothing
    Set Conn = Nothing
    Exit Function
    
ErrInfo:
    ' 显示错误信息
    MsgBox "错误号:" & Err.Number & " 错误信息:" & Err.Description, vbExclamation
    Resume ExeSQl_Exit
End Function

⌨️ 快捷键说明

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