VB import text file for comparison

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • risk32
    New Member
    • Mar 2008
    • 98

    VB import text file for comparison

    Hello. I'm trying to open a file for comparison to two (2) input box text values. ie:
    txtPassword.tex t + ";" + txtUsername.tex t must equal whats in a line in the UNPW (username password) text file locally saved.

    Here's what I have for saving the text file using the preferred format:
    Code:
    Dim FN As Long
    FN = FreeFile
    Open "C:\Documents and Settings\Adam.Martin\Desktop\UNPW.txt" For Output As FN
    Print #FN, txtUsername.Text + ";" + txtPassword.Text
    Close FN
    and here's the other coding I have so far for the comparison:
    Code:
    Dim UNPW As String
    Dim y As String
    Open "C:\Documents and Settings\Adam.Martin\Desktop\UNPW.txt" For Input As 1
    Do Until EOF(1)
    y = InStr(1, 1, txtUsername.tezt + "&" + txtPassword.Text)
    If txtUsername.Text + "&" + txtPassword.Text = y Then
    Unload Me
    frmWelcome.Show
    Else
    Unload Me
    frmUnauthorized.Show
    End If
    End Sub
    Anybody have an idea how I can finish this up?
  • risk32
    New Member
    • Mar 2008
    • 98

    #2
    Nevermind, found my errors... and did it a different way. for those interested:
    Code:
    Private Sub cmdLogin_Click()
    Dim y As String
    Open "C:\Documents and Settings\Adam.Martin\Desktop\UNPW.txt" For Input As #1
    Do Until EOF(1)
    Input #1, y
    Exit Do
    Loop
    Close #1
    If y = txtUsername.Text + "&" + txtPassword.Text Then
    .........

    Comment

    Working...