|
-
May 11th, 2005, 10:25 AM
#1
Thread Starter
Lively Member
Reading from .rtf file [RESOLVED]
Hi there
I am trying to read all of the data from a .rtf file and write it to a Rich Text Box. Now, I have done the same with a .dat file before, with the following code, and it works:
VB Code:
Dim strData As String
Dim hFile As Long
Dim sFilename As String
sFilename = ".\file.dat"
hFile = FreeFile
Open sFilename For Input As #hFile
strData = Input$(LOF(hFile), hFile)
Close #hFile
But when I use file.rtf file in place of file.dat, then it throws the following error:
Run-time error '62'
Input past end of file
Any idea how I could make this work?
Many thanks
langals
Last edited by langals; May 11th, 2005 at 10:44 AM.
Reason: Resolved
-
May 11th, 2005, 10:31 AM
#2
Re: Reading from .rtf file
You know that the RichTextbox has a method called LoadFile which can do this for you 
And, you could try something like this:
VB Code:
Dim strData As String
Dim hFile As Long
Dim sFilename As String
sFilename = ".\file.dat"
hFile = FreeFile
Open sFilename For Input As #hFile
Do Until EOF(hFile)
strData = Input$(LOF(hFile), hFile)
Loop
Close #hFile
Cheers,
RyanJ
Last edited by sciguyryan; May 11th, 2005 at 10:35 AM.
-
May 11th, 2005, 10:43 AM
#3
Thread Starter
Lively Member
Re: Reading from .rtf file
Thanks. That is so much easier than what I was trying.
langals
-
May 11th, 2005, 10:45 AM
#4
Re: Reading from .rtf file
 Originally Posted by langals
Thanks. That is so much easier than what I was trying.
langals
You are welcome langals 
Cheers,
RyanJ
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
|