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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi I am a real novice to VB6. I am

Status
Not open for further replies.
Dec 17, 2002
7
GB
Hi
I am a real novice to VB6. I am trying to create a small application that will when run open a text file and display the contents in a text box. Here's what i have so far and obviously the line Text1.Text = FileSpec dispays the filename rather than the file contents.
Can anyone please tell me where i am goign wrong and what I need to do please
Cheers


Private Sub Form_Load()

Dim fso, File
Dim FileSpec As String

FileSpec = "C:\test.txt"

Set fso = CreateObject("Scripting.FileSystemObject")
Text1.Text = FileSpec


End Sub
 
Dim fso As Scripting.FileSystemObject
Dim tst As Scripting.TextStream
Dim FileSpec as String

Set fso = New Scripting.FileSystemObject
Set tst = fso_OpenTextFile(FileSpec, ForReading, False)
Text1 = tst.ReadAll


Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
Andy
thanx very much but i have errors when running this with which perhaps you are the man to help me.
when i put your code into a new vb project with a text box
(text1.txt) onto the only form i run it and get the error "user defined type not defined" which seems to pick out almost every line in the code starting at the variables. is it possibly an error with my software or something else?
 
You just need to add a reference to your project. Do this by going to:

Project>References

and add a reference to the Microsoft Scripting Runtime.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top