Hey Ive written code for this although its not exactly how you described it.
My method looks through a database for user name and passwords and then authenticates the user so that he can access other forms
Heres the code
Code:
Dim con As New OleDb.OleDbConnection
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = d:\AddressBook.mdb"
Dim sql As String
Dim ds As New DataSet
Dim userID As String
Dim da As New OleDb.OleDbDataAdapter
Dim password As String
Dim int1 As Integer
Dim maxrows As Integer
userID = UsernameText.Text
password = PasswordText.Text
con.Open()
int1 = 0
sql = "SELECT * FROM login"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
maxrows = ds.Tables("AddressBook").Rows.Count
Do Until int1 = 4
If ds.Tables("AddressBook").Rows(int1).Item(0) = userID And ds.Tables("AddressBook").Rows(int1).Item(1) = password Then
Form1.Show()
Me.Hide()
Exit Sub
Else
End If
int1 = int1 + 1
Loop
Dim msg As String
msg = MsgBox("Username/password mismatch!", vbOKCancel)
If msg = 1 Then
Me.Show()
UsernameText.Text = ""
PasswordText.Text = ""
UsernameText.Focus()
Else
Me.Close()
End If
End Sub
.
Hope this helps!