Wednesday, November 27, 2013

Password Login Help


This is just a mach design. The text fie is located in C:\PasswordFile

I want it to open a subsequent form if the user Id and password for that user matches from the text boxes.


Thanks for the quick reply.



You might want to reconsider the location of the file, but that's up to you.


Use the TextFieldParser (set the delimiter to a comma), then read the file. As an example:




Private Sub ReadInputFile(ByVal textFilePath As String)
If My.Computer.FileSystem.FileExists(textFilePath) Then
Using tfp As New Microsoft.VisualBasic.FileIO.TextFieldParser(textFilePath)
With tfp
.TextFieldType = FileIO.FieldType.Delimited
.Delimiters = New String() {","}
' Set the following to true if you have fields
' which are enclosed in quotation marks:
.HasFieldsEnclosedInQuotes = False
End With
Dim currentLineOfText() As String
While Not tfp.EndOfData
Try
currentLineOfText = tfp.ReadFields()
Stop
Catch ex As Exception
MessageBox.Show("An error reading the input file has occurred:" & vbCrLf & vbCrLf & _
ex.Message, "I/O Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End While
End Using
Else
MessageBox.Show("The input text file could not be located.", "File Not Found", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub




The per line, test for the fields to see if you have a match.


Please call me Frank :)


No comments:

Post a Comment