info from file

Posted on 2006-04-24
Last Modified: 2010-05-01
I have this in Accounts.ini


and this in my VB6 but how do I make it so it reads email and password?
WebBrowser.Document.Forms("MailForm").All("email").Value = App.Path & "\Accounts.ini"
WebBrowser.Document.Forms("MailForm").All("password").Value = App.Path & "\Accounts.ini"
Question by:aplelois
    LVL 18

    Expert Comment

    This is an INI format. The following links will help you:

    Use Registry Instead of INI
    Registry is a better way to use instead of INI. Here are two links that will be of help:

    Advantage Of Registry Over INI

    Complete Registry Control
    LVL 28

    Accepted Solution

    If thats all you need from the file you can try something like this:

    Private Type UserInfo
        UserName As String
        Password As String
    End Type

    Private Sub Command1_Click()
    Dim AccInfo As UserInfo
    AccInfo = UserSettings(App.Path & "\accounts.ini")

    MsgBox AccInfo.UserName
    MsgBox AccInfo.Password

    End Sub

    Private Function UserSettings(AccFile As String) As UserInfo
    Dim ff As Integer, fData As String, p As Integer
    ff = FreeFile
    Open AccFile For Input As #ff
    fData = Input$(LOF(ff), ff)
    Close #ff
    p = InStr(fData, "Text_Email=") + 11
    UserSettings.UserName = Trim$(Mid$(fData, p, InStr(p, fData, vbCrLf) - p))
    p = InStr(fData, "Text_Password=") + 14
    UserSettings.Password = Trim$(Mid$(fData, p, InStr(p, fData, vbCrLf) - p))
    End Function

    Author Comment

    thanks for your code.. instead of MsgBox how can I display it as label ?
    LVL 28

    Expert Comment

    Private Sub Command1_Click()
    Dim AccInfo As UserInfo
    AccInfo = UserSettings(App.Path & "\accounts.ini")

    Label1.Caption = AccInfo.UserName
    Label2.Caption = AccInfo.Password

    End Sub

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now