Consulting

Results 1 to 3 of 3

Thread: Solved: Need help in Opening and Reading simple text file.

  1. #1
    VBAX Regular
    Joined
    Dec 2006
    Location
    Kentucky
    Posts
    19
    Location

    Solved: Need help in Opening and Reading simple text file.

    OK gang,
    Being new to the VB world, I need a little more help now. I have been succussful in creating a Userform1 that I want to pull names from. I now need to create a simple text file and store it on my C:\. This should be easy enough. My problem is I need some advice on what might be the best way to store the data in the text file.

    Are there any benefits or downsides to either of the two examples listed?

    Example #1:
    ================================
    Butch Jones, Carol Jones, Sam Jones, Henry Jones,

    Example #2:
    ================================
    Butch Jones
    Carol Jones
    Sam Jones
    Henry Jones


    Second question......
    How would you code to read the data in the above listed text file if they were saved as C:\testfile.txt

    When posting code, could you try and give a small definition as to what is going on so that the "newbie" can follow.... Have to take my baby steps first....

    Thanks in advance,
    Butch

  2. #2
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hi Butch,
    After reading the posts in this thread:
    http://vbaexpress.com/forum/showthread.php?t=10417
    I thought Malcolm had answered this question for you(post 12 and 13)....you just needed to change the path in UserForm_Initialize to this: C:\MyNames.txt and create your file named MyNames.txt and save it to C:\ then run the excel file from anywhere.

    attached zip has the excel file and the text file...save the text file to C:\ and run the excel file......I put this together from info Malcolm provided in the other thread so it's should be nothing new to you but maybe you misunderstood.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Sorry I missed this part:
    saved as C:\testfile.txt
    just change the name of the text file and change the line of code in the initalized statement to C:\testfile.txt
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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