I've made a basic loginform in VS 2005 for anyone to use, 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:Code: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


Reply With Quote
