9 Replies - 2702 Views - Last Post: 27 July 2010 - 09:40 AM Rate Topic: -----

#1 Guest_Geek96*


Reputation:

I forgot how to read from a text file... -_-'

Posted 20 July 2010 - 09:04 AM

Basically, I need to open the file from Textbox1.Text(this stores the path) and dump all the text into the string 'File'.

Example code:
Sub Button1_Click
     OpenFile(1, TextBox1.Text)
     File = FileContents(1)
End Sub


I know this isn't the actual code, it's just an example of what I'm trying to do.
Is This A Good Question/Topic? 0

Replies To: I forgot how to read from a text file... -_-'

#2 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: I forgot how to read from a text file... -_-'

Posted 20 July 2010 - 09:06 AM

Moved to VB.NET. VB.NET Programmers is a discussion forum for more advanced topics, the normal VB.NET forum is for asking help questions :)
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14507
  • View blog
  • Posts: 58,158
  • Joined: 12-June 08

Re: I forgot how to read from a text file... -_-'

Posted 20 July 2010 - 09:11 AM

FileStream buddy...

http://msdn.microsof...filestream.aspx
Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5104
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: I forgot how to read from a text file... -_-'

Posted 20 July 2010 - 09:29 AM

Although I'd suggest a StreamWriter for an easier time writing text.
Was This Post Helpful? 0
  • +
  • -

#5 raziel_   User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,281
  • Joined: 25-March 09

Re: I forgot how to read from a text file... -_-'

Posted 20 July 2010 - 10:02 AM

i think this is vb6 or is not?

This post has been edited by NoBrain: 20 July 2010 - 10:02 AM

Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: I forgot how to read from a text file... -_-'

Posted 20 July 2010 - 10:05 AM

You're right , I didn't even notice that. The code provided is indeed VB6 code so I'm moving this to VB6
Was This Post Helpful? 0
  • +
  • -

#7 raziel_   User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,281
  • Joined: 25-March 09

Re: I forgot how to read from a text file... -_-'

Posted 20 July 2010 - 10:12 AM

about the OP question here is a link that will help you
Reading a Text file Line by Line

good luck :)
Was This Post Helpful? 0
  • +
  • -

#8 NeoTifa   User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4314
  • View blog
  • Posts: 18,706
  • Joined: 24-September 08

Re: I forgot how to read from a text file... -_-'

Posted 20 July 2010 - 12:53 PM

You could use Open "pathname" For mode As filenumber and to read use string = Input(numOfCharacters, #filenumber). The string should contain numOfCharacters worth of the file's text. Hope that helped ^___^

This post has been edited by NeoTifa: 20 July 2010 - 12:54 PM

Was This Post Helpful? 1
  • +
  • -

#9 gen009   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 28
  • Joined: 15-May 09

Re: I forgot how to read from a text file... -_-'

Posted 26 July 2010 - 11:27 PM

    Dim F$
    Open textbox1.text For Binary As #1
    F$ = Space$(LOF(1))
    Get #1, , F$
    Close #1
    File = F$



Hope this helps.. ^_^
Was This Post Helpful? 0
  • +
  • -

#10 born2c0de   User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 187
  • View blog
  • Posts: 4,673
  • Joined: 26-November 04

Re: I forgot how to read from a text file... -_-'

Posted 27 July 2010 - 09:40 AM

You should read these two comprehensive tutorials on Sequential and Binary File Handling here and here for a better understanding of VB6 File Handling.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1