|
-
Nov 24th, 2000, 02:47 AM
#1
Thread Starter
Lively Member
Is it possible add a rich text file in a resource file and load it into a rich text box on form load? I put a RT file in a resource file and can't figure out how to read it into a rtb. Any suggestions??
-
Nov 24th, 2000, 07:58 AM
#2
Lively Member
hi ,
try this code in new form with richtextbox and command button
1 add the two controls
2 resource file select custom do not change the control
3 copy this code in your form
Public objFile As New Scripting.FileSystemObject 'Object for File
Public objFileRead As Scripting.TextStream 'Object for File Opening/reading/writing
Private Sub Command1_Click()
Dim srtbText() As Byte
Dim iCtr As Integer
Dim sVar As String
Dim sFileName As String
srtbText = LoadResData(101, "custom")
sVar = ""
sFileName = "c:\rtf.txt"
For iCtr = 0 To UBound(srtbText)
sVar = sVar & Chr(srtbText(iCtr))
Next iCtr
'temporary file
Call objFile.CreateTextFile(sFileName, True)
Set objFileRead = objFile.OpenTextFile(sFileName, ForAppending)
objFileRead.Write (sVar)
objFileRead.Close
RichTextBox1.LoadFile (sFileName)
End Sub
if worked well else pass on the code
-
Nov 24th, 2000, 10:56 AM
#3
Thread Starter
Lively Member
I see what you're trying to do using a temp file. I tried it and got an overflow at "For iCtr = 0 To UBound(srtbText)"
Any ideas?
Thanks!
-
Nov 24th, 2000, 10:58 AM
#4
Thread Starter
Lively Member
Just changed the iCtr variable to long and it worked!
Dim iCtr As Long
Thanks again!
-
Nov 24th, 2000, 11:52 AM
#5
Thread Starter
Lively Member
The routing was running REALLY slow (it's a large rich text file). I figured out a lightning fast and simple way of reading a rich text file from a resource file:
Just takes a couple of lines....
Private Sub Command1_Click()
Dim srtbText() As Byte
srtbText = StrConv(LoadResData(101, "CUSTOM"), 64)
RichTextBox1.TextRTF = srtbText
End Sub
Regards,
Rich
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
|