小弟最近在做课程设计,在公共模块里写了个对用户进行判断的程序,
但运行提示"用户定义类型未定义"帮我看看吧~!
程序如下:
Sub Main()
Dim fLogin As New frmLogin
fLogin.Show vbModal
If Not fLogin.OK Then
'Login Failed so exit app
End
End If
Unload fLogin
Set fMainForm = New FrmMain
fMainForm.Show
End Sub
但运行提示"用户定义类型未定义"帮我看看吧~!
程序如下:
Sub Main()
Dim fLogin As New frmLogin
fLogin.Show vbModal
If Not fLogin.OK Then
'Login Failed so exit app
End
End If
Unload fLogin
Set fMainForm = New FrmMain
fMainForm.Show
End Sub
Public UserName As String--------------------------------------------------------------------------
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.Execute SQL
MsgString = sTokens(0) & "query successful"
Else
Set rst = New ADODB.Recordset
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
'rst.MoveLast 'get RecordCount
Set ExecuteSQL = rst
MsgString = "查询到" & rst.RecordCount & "条记录"
End If
ExecuteSQL_Exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
ExecuteSQL_Error:
MsgString = "" & Err.Description
Resume ExecuteSQL_Exit
End Function
--------------------------------------------------------------------------------
Public Function ConnectString() As StringConnectString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=student;Data Source=YANG-AC19BCFA98"End Function
---------------------------------------------------------------
Public Function Texttxt(txt As String) As Boolean If Trim(txt) = "" Then
Texttxt = False
Else
Texttxt = True
End If
End Function
--------------------------------------------
Sub Main()
Dim fLogin As New frmLogin '提示在这行出错
fLogin.Show vbModal
If Not fLogin.OK Then
'Login Failed so exit app
End
End If
Unload fLogin
Set fMainForm = New FrmMain
fMainForm.Show
End Sub