VS2005/2008 Login Form

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,530
Location
Lansing, MI; USA
Programming Experience
10+
I've made a basic loginform in VS 2005 for anyone to use (Continued from the VS 2003 version), here's the zip file containing the form, feel free to use & modify it freely ... you dont even need to tell me about it

How it works:
Make an instance of it then you can set the properties UserId, Password, UserIdMaxLength and PasswordMaxLength then just call the the ShowDialog method
I've provided some other ShowDialog signatures that allows those properties to be set with only 1 ShowDialog call

When the Login button is clicked on the window you can retrieve the UserID and Password from their respective properties

This works with the DialogResult object as well so you can easily check to see if the cancel button was clicked or not

Properties to pay attention to:
*Title - Shows in the window's caption bar
*UserID - Default value for the UserID textbox
*Password - Default value for the Password textbox
*UserIDMaxLength - The max chars for UserID
*PasswordMaxLength - The max chars for Password
*AllowUserIDNull - Allow the UserID to be blank? Default is False.
*AllowPasswordNull - Allow the UPassword to be blank? Default is False.

Here's a quick example on how to use the LoginForm:
VB.NET:
Dim UserID, Password As String

m_Login = New LoginForm
With m_Login
    .Owner = Me
    .UserIDMaxLength = 16I 'Limit number of chars
    .PasswordMaxLength = 16I
    .AllowPasswordNull = True
    If .ShowDialog("Login to the system", "Neo") = Windows.Forms.DialogResult.OK Then
        'Use properties to get info back:
        UserID = .UserID
        Password = .Password
        MessageBox.Show("Possible success!")
    Else
        MessageBox.Show("Canceled!")
    End If
End With
 

Attachments

  • LoginForm.zip
    4.2 KB · Views: 430
  • LoginFormDemo.zip
    18.4 KB · Views: 378
A good thing, worthy of reference.
But it looks like you have only one login. You may try an integrated windows logon and domain login mode.
Expecting...
 
A good thing, worthy of reference.
But it looks like you have only one login. You may try an integrated windows logon and domain login mode.
Expecting...
You can use this for that, all this form does is get the info from the user, it's up to you to do the validation code behind the scenes and you can have it check against any data source you want.
 
Back
Top