In the VB IDE, go to the 'Project' menu item, then go down to 'References'. Scroll through that list until you find 'Microsoft Scripting Runtime', check that option and click 'OK'. Then Giles code will work. Actually, I just noticed Giles has an error in his code, it should actually be:
Dim fso As FileSystemObject
Dim txtstr As TextStream
Dim tempstring As String
Set fso = New FileSystemObject
Set txtstr = fso.opentextfile("C:test.txt", forreading, False)
With txtstr
tempstring = .readall
.Close
End With
Set txtstr = Nothing
Set fso = Nothing
And remember Tempstring will hold all your text after it's executed.
Also, the more 'conventional' method for opening files in VB (which doesn't require the MS Scripting Runtime reference) is to just use this:
Dim Variable As String
Open "C:Test.txt" For Input As #1
Input #1, Variable
Close #1
Obviously 'Variable' will hold your text, although, that code will only pull out the first 'segment' of the file, a 'segment' being a line of text in a file until a comma is reached, i.e. If your file looked like:
"Testing this file, Ok it's good
Now onto a new line"
That code will only pull the "Testing this file" part, which is why this code is only really good if you've already saved to the text file previously with VB, so you can easily match the format.
"Computers are useless they can only give you answers."