|
-
Aug 29th, 2000, 10:24 PM
#1
Thread Starter
New Member
im using commondialog, i want to open a .doc, or .txt, whatever.. and load it into a richtext box. but i always get errors.. anyone know how.. thanks
later
-
Aug 29th, 2000, 10:40 PM
#2
Try this:
Code:
Private Sub Command1_Click()
Dim iFile As Integer
On Error GoTo User_Cancelled
With CommonDialog1
.CancelError = True
.DialogTitle = "Select a Text File.."
.Filter = "Txt Files (*.txt)|*.txt|Doc Files (*.doc)|*.doc"
.ShowOpen
iFile = FreeFile
Open .filename For Input As iFile
RichTextBox1.text = Input(LOF(iFile), iFile)
Close iFile
End With
User_Cancelled:
End Sub
-
Aug 29th, 2000, 10:47 PM
#3
Guru
That will only work with TXT files.
For opening TXT and RTF, you can use the LoadFile method.
I think it's:
Code:
' Text files:
RichTextBox1.LoadFile("C:\MyFile.txt", vbCFText)
' RichText files:
RichTextBox1.LoadFile("C:\MyFile.rtf", vbCFRTF)
If it's not LoadFile then it's FileLoad or OpenFile or FileOpen or maybe I'm just tired...
-
Aug 29th, 2000, 11:13 PM
#4
Thread Starter
New Member
yea.. i finally seen that loadfile. im a retard..
thanks
later
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
|