?? module1.bas
字號(hào):
Attribute VB_Name = "Module1"
Public UserName As String
Public txtSQL As String 'use to store record SQLsentence
Public dream As ADODB.Recordset 'use to store record object
Public Msgtext As String '用來存放返回信息
Public OK As Boolean '
'Public db As String
Public Sub highlight()
With Screen.ActiveForm
If (TypeOf .ActiveControl Is TextBox) Then
.ActiveControl.SelStart = 0
.ActiveControl.SelLength = Len(.ActiveControl)
End If
End With
End Sub
Sub Main()
'Dim Login As New Login
'Login.Show vbModal
'f Not Login.OK Then
'Login Failed so exit app
' End
'End If
'Unload studentmdi
' Set login = New login
login.Show
End Sub
Public Function connectstring() As String
connectstring = "Provider=Microsoft.jet.OLEDB.3.51;Data source=f:\schoolgroup\school.mdb"
End Function
Public Function ExecuteSQL(ByVal SQL As String, Msgstring As String) As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sTokens() As String
On Error GoTo ExecuteSQL_Error
sTokens = Split(SQL)
Set cnn = New ADODB.Connection
cnn.Open connectstring
If InStr("INSERT,DELETE,UPDATE", UCase$(sTokens(0))) Then
cnn.ExecuteSQL
Msgstring = sTokens(0) & "query successful"
Else
Set rst = New ADODB.Recordset
rst.Open Trim(SQL), cnn, adOpenKeyset, adLockOptimistic
Set ExecuteSQL = rst
Msgstring = "查詢到" & rst.RecordCount & " 條記錄"
End If
executeSQL_exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
ExecuteSQL_Error:
Msgstring = "查詢錯(cuò)誤:" & err.Description
Resume executeSQL_exit
End Function
Public Function Testtxt(txt As String) As Boolean
If Trim(txt) = "" Then
Testtxt = False
Else
Testtxt = True
End If
End Function
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -