So i have small problem. Idk how to explain so we will go like this. I have 2 projects. 1. MyLib its compiled .dll 2. MyApp its compiled .exe

Okay now Mylib has form, and MyApp has form. So there are 2 forms. Mylib form is login form with 2 textboxes for login and password and 'Login' named Button! MyApp form should be opened after you enter correct data to MyLib login form.

Also Mylib form has cases, so when you click button it will show case 1 messagebox with wrong username, case 2 messagebox with wrong password and case 3 should open form from MyApp.

How to do it?

I haven't ever tried it, but this article talks about it. Click "Project" => "Add Reference" => "Browse" => <your dll> => "OK".

Then add Imports YourDLL

Create an instance of your class and call the method to show the form.

.... I already said i did that. I can open dll form from .exe i need to open .exe form after clicking login and details are correct in dll form..

If you have control over the .dll source code, make the login form modal(.ShowDialog) and open it in the Load event handler of the .exe form. If the dialog result is good continue loading the .exe form. If it's bad try again or quit altogether.

@tinstaffl Could you show me example of it how to do please?

Basically set the Accept Button and the Cancel Button properties of the login form. In the Click event handler for each button set the form's DialogResult property to the desired one. Now in the .exe form's Load event handler call the .dll's form. This will probably require instantiating the class first. Then create a DialogResult object instantiated with the ShowDialog method of the .dll form. Something like this:

Dim NewMyLib As New MyLib
Sub Form1_Load(Sender as Object, E As EventArgs) Handles Form1.Load
    Dim Result As DialogResult = MyLib.LoginForm.ShowDialog
    If Result <> DialogResult.OK Then
        Me.Close
    End If
End Sub

This is on the fly, some of the syntax might not be 100% correct, but you should be able to get the general idea.

For property settings it's usually better to do them in the designer. The rest of it probably should be in code.

This article has been dead for over six months. Start a new discussion instead.