Hi,
Last week, I asked a question how to get a file in a textbox when the
file is over than 64K and the answer I've got worked but now i have 2 others
questions:
1) Is there a way to control the color of the characters in a RichTextBox
control, if Yes, How???
2) And also, Depending on the using machine is there a way to trap the "Out
of Memory" Run-time error 7...
I tried to trap it with the statement:
On Error Goto ErrorHandler
......
.....
and it didn't work???
I tried also the trapping way before the critical line of loading text in
the richtextbox followed by a select case errnumber and it didn't work
also???
More Specifications:
This error is coming when i'm loading a file in a RichtextBox by opening a
file wich it's a public event procedure like this:
Public OpenFile(byref strFile as string)
Dim intFileNumber As Integer
Dim frmDocument As Form
Dim lngFileLength As Long
On Error GoTo ErrorHandler
Set frmDocument = New frmEditor
' Obtient le prochain entier disponible
intFileNumber = FreeFile
frmDocument.Show
frmDocument.Caption = UCase(strNameOfFile)
' Obtient la longueur du fichier texte
lngFileLength = FileLen(strNameOfFile)
' Ouvre le fichier texte et le met dans l'instance
' de l'objet frmDocument.txtTexteSource
Open strNameOfFile For Input As #intFileNumber
' Si jamais le fichier depasse 64K (Limite du controle
' textbox), alors on l'ouvre avec un controle richTextBox.
If lngFileLength < 65000 Then
frmDocument.txtTexteSource.Text = StrConv(InputB(LOF(1), 1),
vbUnicode)
Else
frmDocument.txtTexteSource.Visible = False
frmDocument.rtfTexteSource.Visible = True
frmDocument.rtfTexteSource.Text = StrConv(InputB(LOF(1), 1),
vbUnicode)
End If
Close #intFileNumber
ExitProcedure:
Exit Sub
ErrorHandler:
MsgBox "Hello"
MsgBox Err.Number & ":" & Err.Description
Close #intFileNumber
Resume ExitProcedure
End Sub
PS. Sorry, for the french comments!!!
Thanks in advance!