• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Loading Diferent forms or projects depending on login.

RE: Visual Basic 2008
I need some advice.

I have a login form that determines the users group. Depending on the user and group the startup form or subforms may be differnt.

I tried to load different forms by Instantiating a string value saved to the users table.
   InstantiateThis += Staff.MainFormName.Trim
   frm = System.Activator.CreateInstance(Nothing, InstantiateThis).Unwrap()

Although this works, as design time I am unable to refer to the forms object as frm.object without a huge cluster of compied errors because I have to declare every single object.
Bottom line this does not save time !

So, I'm thinking of creating a new project (since they will be different) and having the login project determine which project to start.

 - How do I start another project within the solution ?
 - if the only way to start it is using a shell command then how can I read the projects installed location ?

Whatis Project Depensies used for ?


Does anyone have any advice on how to accomplish having different forms and modules loaded depending on the login name or group ?





Public Class Login
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Select Case (Me.UsernameTextBox.Text).ToLower
            Case "simon"
                ' Load project called Claims
            Case "fred"
                ' Load project called pi
            Case "sam"
                ' Load project called Claims
            Case Else
                MsgBox("Username not valid", MsgBoxStyle.Exclamation, "Incorrect username")
                Me.Close()
        End Select
 
    End Sub
 
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub
 
End Class

Open in new window

0
siacom
Asked:
siacom
1 Solution
 
Priest04Commented:
If the projects will be different, then it is reasonable to put them in separate exe's. You can have one LogIn.exe that will allow user to choose the group, and based on the selected group you will launch a corresponding exe. As for getting projects installation paths, I guess it would be the best to write the path to some .txt file, which will be read by your logIn application. This file will contain a list of all installed projects.

To run the application from LogIn application:

System.Diagnostics.Process.Start(ApplicationPathAndName);

Goran
0
 
siacomAuthor Commented:
Sweet, I'll try that way, thanks
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now