小弟最近在做课程设计,在公共模块里写了个对用户进行判断的程序,
但运行提示"用户定义类型未定义"帮我看看吧~!
程序如下:
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

解决方案 »

  1.   

    你把代码贴全frmLogin、FrmMain这两个窗体你有吗,检查一下是否拼错了?另外,是哪一句出现问题
      

  2.   

    谢谢大哥~!
    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
      

  3.   

    // Dim fLogin As New frmLogin '提示在这行出错代码没问题,你的程序中有名为frmLogin的窗体吗?你的工程如果没有名为frmLogin的窗体的话,才会产生错误