|
-
January 5th, 2000, 09:32 PM
#1
Inputing files
i am trying to input a txt file into a textbox, how would i do that?
-
January 5th, 2000, 10:25 PM
#2
Re: Inputing files
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...
-
January 6th, 2000, 03:34 AM
#3
Re: Inputing files
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|