Read file line by line and... - basic.visual

This is a discussion on Read file line by line and... - basic.visual ; I want the user to be able to write like http://www.google.com in one textBox and Google in an other textBox. Than I want the user to press a button when done. The text will then be past like http://www.google.com,Google in ...

+ Reply to Thread
Results 1 to 2 of 2

Read file line by line and...

  1. Default Read file line by line and...


    I want the user to be able to write like http://www.google.com in one
    textBox and Google in an other textBox.

    Than I want the user to press a button when done. The text will then be past
    like http://www.google.com,Google in to a file.

    I want the user to be able to send as many links with names as they want to
    that file. Then I want my program to be able to read from that file as I
    start the program from a button at my form and use it in the program.

    I am using MS Agent and I want the user to be able to write down links like
    i described and then when I start the agent I want the agent to "build"
    this:

    All the names the user wrote:

    Merlin.Commands.RemoveAll
    Merlin.Commands.Add "Google", "Google", "Google"
    Merlin.Commands.Add "Lunarstorm", "Lunarstorm", "Lunarstorm"
    Merlin.Commands.Add "Back", "Back", "Back"
    Merlin.Commands.Add "Forward", "Forward", "Forward"
    Merlin.Commands.Add "Close", "Close", "Close"

    The Names and the URL the user wrote down:

    Select Case UserInput.Name
    Case "Google"
    URL= "http://www.google.se"
    objInternet.Navigate Adress
    Case "Lunarstorm"
    URL= "http://www.lunarstorm.se"
    objInternet.Navigate Adress

    Case "Back"
    objInternet.Back
    Case "Forward"
    objInternet.Forward

    Case "Close"
    objInternet.Quit
    End Select

    I want to do something like this:

    Read the file line by line split the line at the "," and pot the left and
    right string in an array and then go to the next line and add that to the
    array as well and so on.

    Then I want to use it in the MS Agent as this, to be able to use the links:
    (As the Link names is the odd numbers I will just write out the odd
    numbers.)

    for (i=1, i<= aryLength(aryLink[i]), i=+2)
    {
    Merlin.Commands.Add "aryLinks[i]", "aryLinks[i]", "aryLinks[i]"
    }

    Merlin.Commands.Add "Back", "Back", "Back"
    Merlin.Commands.Add "Forward", "Forward", "Forward"
    Merlin.Commands.Add "Close", "Close", "Close"


    Then here it is a little harder, the Case Is the odd numbers in the Array
    and the URL is the even numbers.

    Select Case UserInput.Name

    Case "Google"
    URL= "http://www.google.se"
    objInternet.Navigate URL
    Case "Lunarstorm"
    URL= "http://www.lunarstorm.se"
    objInternet.Navigate URL

    These are not taken from the file:
    Case "Back"
    objInternet.Back
    Case "Forward"
    objInternet.Forward
    Case "Close"
    objInternet.Quit
    End Select

    As you can see is this not a language that exist... I don't know how to do
    it in VB 6 It is not the same as using PHP with mySQL...

    I'm a newbe to VB and some other languages as well...So it's all a bit
    confusing...

    Plz show me in the right direction to get this to work :-)



  2. Default Re: Read file line by line and...

    This is what I have done...
    But I don't know how to use the Arrays that I need, so if anyone know this
    you are very welcome to show me

    I am reading from a text file containing this:


    http://www.google.com,Google
    http://www.lunarstorm.se,Lunarstorm
    http://www.microsoft.com,Microsoft

    With this function:


    Option Explicit

    Public URLAddress As String
    Public NameAddress As String

    Public Static Function ReadFile()

    Const ForReading = 1, ForWriting = 2
    Dim fso, f
    Dim LineHolder As String
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
    LineHolder = f.ReadLine

    Dim MyString, MyArray
    MyString = Split(LineHolder, ",", -1, 1)

    ' *** MyString(0) contains "http://www.google.com".
    ' *** MyString(1) contains "Google".
    ' *** MyString(2) contains " http://www.google.com".
    ' *** MyString(3) contains "Lunarstorm".
    ' *** (all odd numbers are URL's and all the even numbers are the Names)


    URLAddress = MyString(0) '***** This Must Contain all even numbers,
    0,2,4...
    NameAddress = MyString(1) '***** This Must Contain all odd numbers,
    1,3,5,...


    End Function


    '******I want to produce this:

    Case "Google"
    Address = "http://www.Google.com"
    objInternet.Navigate Address



    Case "Lunarstorm"
    Address = "http://www.lunarstorm.se"
    objInternet.Navigate Address

    Case "Microsoft"
    Address = "http://www.Microsoft.com"
    objInternet.Navigate Address


    '***** By looping the URLAddress and NameAddress

    Case NameAddress
    Address =URLAddress
    objInternet.Navigate Address

    Yours, Jonas



+ Reply to Thread

Similar Threads

  1. Read from file line by line
    By Application Development in forum CSharp
    Replies: 17
    Last Post: 10-02-2007, 05:44 PM
  2. Replies: 3
    Last Post: 09-18-2007, 11:53 PM
  3. How to read .txt file line by line
    By Application Development in forum Javascript
    Replies: 2
    Last Post: 04-17-2007, 05:43 AM
  4. how to read cell data line by line from excel using vb script in macro?
    By Application Development in forum Inetserver
    Replies: 1
    Last Post: 03-27-2007, 06:37 PM
  5. How to read a pdf file line by line through IAC
    By Application Development in forum Adobe Acrobat
    Replies: 6
    Last Post: 08-01-2006, 06:26 AM