Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can i link a text box to a txt file?

Status
Not open for further replies.

adi316

Programmer
Sep 10, 2002
35
CA
can i make it so a text box is actually a txt file? so the textbox displays the contents of the file.
 
Option Explicit

Private Sub Form_Load()
Dim fso As FileSystemObject
Dim tsTextStream As TextStream

Set fso = New FileSystemObject
Set tsTextStream = fso_OpenTextFile("C:\Text.txt", ForReading)

Me.Text1 = tsTextStream.ReadAll

tsTextStream.Close
Set tsTextStream = Nothing
Set fso = Nothing


End Sub
 
And make sure to add a reference to the Microsoft Scripting runtime ( Project/ References menu ). or you will get an error on the dim FSO statement.

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top