i am trying to input a txt file into a textbox, how would i do that?
Printable View
i am trying to input a txt file into a textbox, how would i do that?
i think you can look this up at one of the free books at InformIT library.
http://www.informit.com/library/
That should answer some of your questions regarding file i/o.
____________________________________
The VB Bugs in my Life...
There's a really simple method at http://codeguru.developer.com/vb/articles/1764.shtml - here's a summary of the code :
public Function ReadFile(FileName as string) as string
'
Dim i as Integer
i = FreeFile
'
on error GoTo ErrorTrap
'
Open FileName for input as #i
ReadFile = input(LOF(i), i)
Close #i
'
Exit Function
'
ErrorTrap:
'
ReadFile = ""
'
End Function
'
public Sub WriteFile(FileName as string, Contents as string)
'
Dim i as Integer
i = FreeFile
'
Open FileName for Output as #i
'
print #i, Contents
Close #i
'
End Sub
Using this code you can populate a MultiLine textbox (eg. Text1) with the contents of Config.Sys using :
Text1.Text = ReadFile("c:\config.sys")
and write away the contents of Text1 to a file using :
Call WriteFile("c:\whatever.whatever", Text1.Text)
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb