Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 26th, 2005, 11:11 PM   #1
ViOLATiON
Programmer
 
Join Date: Sep 2005
Posts: 58
Rep Power: 4 ViOLATiON is on a distinguished road
Using Text Files...

Ok, I've made a textbox sort of like a text editor (ie: notepad), but I would like it to read the text in the textbox from a .txt file .. I think thats how you say it.. :eek:

The reason for this is because its going to be a fairly long paragraph.

Here's a quick little diagram to help clear things up



<3 mspaint

I'm sure this is really easy, maybe I'm using the wrong words on Google.

EDIT: I've found this:

Dim Myfile As String
'Replace "c:\testfile.txt
file = "c:\testfile.txt"
Open Myfile For Input As #1
Text1.Text = Input(LOF(1), #1)
Close

When i run it i get an error, i click Debug and the line Open Myfile For Input As #1 is highlighted.

Any ideas?

Thanks in advance

Last edited by ViOLATiON; Oct 26th, 2005 at 11:22 PM.
ViOLATiON is offline   Reply With Quote
Old Oct 26th, 2005, 11:53 PM   #2
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4 Ghost is on a distinguished road
What version of Visual Basic?

In VB.NET I believe:
FileStream file = new FileStream("C:\textfile.txt",FileMode.OpenOrCreate, FileAccess.Read)
StreamReader sr = new StreamReader(file)

Text1.Text = sr.ToString()
Ghost is offline   Reply With Quote
Old Oct 26th, 2005, 11:55 PM   #3
ViOLATiON
Programmer
 
Join Date: Sep 2005
Posts: 58
Rep Power: 4 ViOLATiON is on a distinguished road
New idea, is to make it read HTML files. I downloaded the MozillaControl 1.0 Type Library, and the code I have right now is:

MozillaBrowser1.Navigate ("file.html")

Where file.html is in the same dir as the exe, but it won't find it unless I put the direct path in the source code (ie: c:\app\file.html), and that sucks because everyone wont have it in the same place.

Anyway around this? I've tried ("\file.html"), same thing.

Thanks guys.
ViOLATiON is offline   Reply With Quote
Old Oct 26th, 2005, 11:55 PM   #4
ViOLATiON
Programmer
 
Join Date: Sep 2005
Posts: 58
Rep Power: 4 ViOLATiON is on a distinguished road
Quote:
Originally Posted by Ghost
What version of Visual Basic?

In VB.NET I believe:
FileStream file = new FileStream("C:\textfile.txt",FileMode.OpenOrCreate, FileAccess.Read)
StreamReader sr = new StreamReader(file)

Text1.Text = sr.ToString()
If it were VB.NET it would be in the VB.NET forum :p

I'm running VB 6
ViOLATiON is offline   Reply With Quote
Old Oct 26th, 2005, 11:56 PM   #5
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4 Ghost is on a distinguished road
Sorry, I got a direct link from the home page....lets see really quick here....
Ghost is offline   Reply With Quote
Old Oct 27th, 2005, 12:01 AM   #6
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4 Ghost is on a distinguished road
Use the source from a really old project I have. I don't have VB6 anymore or I'd post it for you and I can't remember it correctly, so here is my program's source.
Attached Files
File Type: zip AM_Source.zip (4.9 KB, 28 views)
Ghost is offline   Reply With Quote
Old Oct 27th, 2005, 2:02 AM   #7
ivan
Professional Programmer
 
ivan's Avatar
 
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4 ivan is on a distinguished road
Quote:
Originally Posted by ViOLATiON
Dim Myfile As String
'Replace "c:\testfile.txt
file = "c:\testfile.txt"
Open Myfile For Input As #1
Text1.Text = Input(LOF(1), #1)
Close
Thanks in advance
Instead of:
file = "c:\testfile.txt"
Write:
Myfile = "c:\testfile.txt"
ivan is offline   Reply With Quote
Old Oct 27th, 2005, 3:20 AM   #8
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
Good to see a well posted question.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Oct 27th, 2005, 10:08 AM   #9
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Indeed. Nevertheless Option Explicit would have avoided this problem.
Rory is offline   Reply With Quote
Old Oct 27th, 2005, 1:40 PM   #10
ViOLATiON
Programmer
 
Join Date: Sep 2005
Posts: 58
Rep Power: 4 ViOLATiON is on a distinguished road
Thank you ivan, you proved the title below your name

@coldDeath, i figure if I want an answer I should atleast post it so people will understand. I think my sweet diagram helped :p
ViOLATiON is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:31 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC