Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2013

    Unanswered: how to load username and password

    Good day
    All filename .txt in folder shows in combo box, the problem is i want to use click event,
    If i click one of filename in combo, the text file will load in 2 different textbox (usrnametextbox and passwordtextbox).
    This is a sample of my text file in 1 filename:

    Code for this pls. thanks.

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 14
    Not sure to understand. Here's how I interpret your request:
    - A combobox contains a list of filenames.
    - The first line of each file contains a username.
    - The second line of each file contains a password.

    When you select a filename in the combo (= AfterUpdate event, not Click event), you want a procedure that:
    - Opens the corresponding file (the one selected in the combo).
    - Reads the first line (username) and places its contents in a textbox (usrnametextbox )
    - Reads the second line and places its contents in another textbox (passwordtextbox).

    If I'm right, here's a solution:
    Private Sub Combo_Files_AfterUpdate()
        Dim intHandle As Integer
        Dim strLine As String
        If Len(Dir(Nz(Me.Combo_Files.Value, ""))) > 0 Then
            intHandle = FreeFile
            Open Me.Combo_Files.Value For Input As intHandle
            Line Input #intHandle, strLine
            Me.usrnametextbox = strLine
            Line Input #intHandle, strLine
            Me.passwordtextbox = strLine
            Close #intHandle
        End If
    End Sub
    Note: If the files are not in the default Access folder and the combo does not contains the full path for each file, you'll have to supply it in the lines using the expression Me.Combo_Files.Value
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts