Author | Message | Time |
---|---|---|
DaRk-FeAnOr | [code] Close #1 Open (App.Path & "\Font.txt") For Input As #1 Dim pos As Byte Dim array(10) as string pos = 0 Do Input #1, array(pos) pos = pos + 1 Loop Until EOF(1) [/code] Above is a sample of the kind of reading from .txt file that I am talking about. It seems to me that VB 6 discards all of the spaces before the first character on the line. So, if you have a line like this: blah it will read it as: blah For what I am working on (text art stuff), the spaces before the first char are important, so I was woundering if anybody knows a way to get around this space discarding? Thank you for any help you can offer. | December 18, 2003, 4:56 AM |
Grok | I think you want this instead: [code] Dim nF As Integer Dim Fn As String Dim L As String Fn = "C:\Temp\Somefile.txt" nF = FreeFile Open Fn For Input As #nF Do While Not EOF(nF) Line Input #nF, L Loop [/code] | December 18, 2003, 7:22 AM |
DaRk-FeAnOr | Just replaced Input with Line Input and that made it work. Thanks a lot grok :P | December 18, 2003, 3:28 PM |
Grok | [quote author=DaRk-FeAnOr link=board=31;threadid=4322;start=0#msg36178 date=1071761294] Just replaced Input with Line Input and that made it work. Thanks a lot grok :P [/quote] Fix the other stuff too. Make it a habit to always use FreeFile to get a file handle. Don't assume #1 or #2, etc, is available. | December 18, 2003, 4:02 PM |
Stealth | [quote author=Grok link=board=31;threadid=4322;start=0#msg36184 date=1071763337] [quote author=DaRk-FeAnOr link=board=31;threadid=4322;start=0#msg36178 date=1071761294] Just replaced Input with Line Input and that made it work. Thanks a lot grok :P [/quote] Fix the other stuff too. Make it a habit to always use FreeFile to get a file handle. Don't assume #1 or #2, etc, is available. [/quote] Especially if you've been using #1 or #2 elsewhere and forgot to close them. Input is used with the Write statement to get and retrieve VB comma-separated data from a textfile, while Line Input gets a simple line of text. Input will stop reading at commas as well as the problem you have above. | December 19, 2003, 3:19 AM |
Adron | No, don't use #1 and #2, use #42! Much less risk of that being used already since everyone else uses #1 and #2. | December 19, 2003, 12:40 PM |