Anchor Blue
January 5th, 2000, 08:32 PM
i am trying to input a txt file into a textbox, how would i do that?
|
Click to See Complete Forum and Search --> : Inputing files Anchor Blue January 5th, 2000, 08:32 PM i am trying to input a txt file into a textbox, how would i do that? valkyrie January 5th, 2000, 09:25 PM 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... Chris Eastwood January 6th, 2000, 02:34 AM 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 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |