[Webinar] Streamline your web hosting managementRegister Today


open text file in VB5

Posted on 1999-12-13
Medium Priority
Last Modified: 2010-05-02
Please someone tell me the code for opening a text file.

    Dim txtObject As Object
Set txtObject = GetObject("h:\readme.txt")
Doesn't work.
Question by:englishman
LVL 43

Accepted Solution

TimCottee earned 120 total points
ID: 2276433
What do you want to do with the text file ? If you want to open it and read in the text then you need to use the following.

Open "h:\readme.txt" For Input As #1
Line Input #1,txtLine
debug.print txtLine
Close #1

This will read in the contents line by line and display in the immediate window.

If you want to display this in a form, then you could add the lines read to a textbox.

If you want to display the contents in notepad for examples then use the shell command:

Shell "notepad.exe h:\readme.txt"


Author Comment

ID: 2276460

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

612 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