Visual Basic中的“回调”?

时间:2014-02-25 05:25:33

标签: vb.net dll callback

我有一个新问题。我刚学会了如何在Visual Basic 12中创建和导入DLL。我已经走了很远。但我的问题是,我不知道如何调用属于另一个项目的对象。

我的意思是:

我有2个项目。一个是调用DLL的EXE。另一个显然是DLL本身。

这是DLL:

Public Class sys_auth
    Private cs As String
    Private pw As String
    Public Function auth()
        cs = TextBoxFromOtherProject.Text           [HOW DO I DO THIS?!]
        pw = AnotherTextBoxFromOtherProject.Text    [HOW DO I DO THIS?!]
        Select Case cs
            Case "MehName"
                If pw = "MehPassword" Then
                    MsgBox("Authentication successful!", MsgBoxStyle.Information, "Success")
                    Return True
                Else
                    Return False

                End If

            Case "YoName"
                If pw = "YoPassword" Then
                    MsgBox("Authentication successful!", MsgBoxStyle.Information, "Success")
                    Return True
                Else
                    Return False

                End If

            Case Else
                Return False

        End Select

    End Function
End Class

我怎么称呼它?

1 个答案:

答案 0 :(得分:0)

您可能只想在方法中添加两个参数,例如:

Public Class sys_auth

    Public Function auth(cs As String, pw As String) As Boolean
        Select Case cs
            Case "MehName"
            ...

并从您的其他项目中调用它:

Dim result = New sys_auth().auth(TextBoxFromOtherProject.Text, AnotherTextBoxFromOtherProject.Text)