Out of Memory Error 7! 
Author Message
 Out of Memory Error 7!

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!



Mon, 03 Dec 2001 03:00:00 GMT  
 Out of Memory Error 7!
Use the SelColor property to change the color, You will need to set the
SelStart and Sellength properties first.

As for the Out of Memory problem, I had the answer, but now I've forgotten
it.


Quote:
> 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!



Wed, 05 Dec 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Out of Memory Error & 64K memory limit

2. memory (out of memory error)

3. university EMR send outs

4. on the outs

5. Learning the ins and outs of Peek and Poke

6. How to handle print outs in VB?

7. Filesystem Time outs

8. Session Variable Time-outs

9. Time-outs

10. Need help with time outs

11. Error 7 - Out of Memory Error

12. No error reported and memory leak if error occurs in Class_Terminate

 

 
Powered by phpBB® Forum Software