Aug 6th, 1999, 12:01 AM
I built a small freeform database program (ADO) using VB6 Pro and Access. The Program has a Treeview and one RichTextBox divided by a splitter bar.
The program works well otherwise, but I am unable to get any of the RichText features to work.
The problem is that when I select ANY one of the RichText features, I get RunTime "Error 91" "Object variable or With block variable not set." I am told that VB is saying there's no RichText Control on the Form.
My guess is that the error message is occuring because the RichText Control is on a User Control and not on Form Main, but I do not know how to rewrite the following code to make it work.
Can someone please help me?
Thanks!
jaxon
(NOTE: The following code is part of Microsoft's example for coding RichText features. I also tried three other, perhaps better, sections of code suggested by my VB Brothers. The program ran with all of them but gave the same Run-Time Error '91' when you tried to use the RichText features.)
Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button)
Select Case UCase$(Button.Tag)
Case "BOLD"
' If the MixedState property is True set it to False.
If IsNull(RichTextBox1.SelBold) = True Then
' Code to run when selection is mixed.
RichTextBox1.SelBold = False
ElseIf RichTextBox1.SelBold = False Then
' Code to run when selection is not bold to toggle SelBold property to True.
RichTextBox1.SelBold = Abs(RichTextBox1.SelBold) - 1
End If
Case "ITALIC"
' If the MixedState property is True set it to False.
If IsNull(RichTextBox1.SelItalic) = True Then
' Code to run when selection is mixed.
RichTextBox1.SelItelic = False
ElseIf RichTextBox1.SelItalic = False Then
' Code to run when selection is not Italic to toggle SelItalic property to True.
RichTextBox1.SelItalic = Abs(RichTextBox1.SelItalic) - 1
End If
Case "UNDERLINE"
' If the MixedState property is True set it to False.
If IsNull(RichTextBox1.SelUnderline) = True Then
' Code to run when selection is mixed.
RichTextBox1.SelUnderline = False
ElseIf RichTextBox1.SelUnderline = False Then
' Code to run when selection is not Underlined to toggle SelUnderlined property to True.
RichTextBox1.SelUnderline = Abs(RichTextBox1.SelUnderline) - 1
End If
End Select
End Sub
The program works well otherwise, but I am unable to get any of the RichText features to work.
The problem is that when I select ANY one of the RichText features, I get RunTime "Error 91" "Object variable or With block variable not set." I am told that VB is saying there's no RichText Control on the Form.
My guess is that the error message is occuring because the RichText Control is on a User Control and not on Form Main, but I do not know how to rewrite the following code to make it work.
Can someone please help me?
Thanks!
jaxon
(NOTE: The following code is part of Microsoft's example for coding RichText features. I also tried three other, perhaps better, sections of code suggested by my VB Brothers. The program ran with all of them but gave the same Run-Time Error '91' when you tried to use the RichText features.)
Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button)
Select Case UCase$(Button.Tag)
Case "BOLD"
' If the MixedState property is True set it to False.
If IsNull(RichTextBox1.SelBold) = True Then
' Code to run when selection is mixed.
RichTextBox1.SelBold = False
ElseIf RichTextBox1.SelBold = False Then
' Code to run when selection is not bold to toggle SelBold property to True.
RichTextBox1.SelBold = Abs(RichTextBox1.SelBold) - 1
End If
Case "ITALIC"
' If the MixedState property is True set it to False.
If IsNull(RichTextBox1.SelItalic) = True Then
' Code to run when selection is mixed.
RichTextBox1.SelItelic = False
ElseIf RichTextBox1.SelItalic = False Then
' Code to run when selection is not Italic to toggle SelItalic property to True.
RichTextBox1.SelItalic = Abs(RichTextBox1.SelItalic) - 1
End If
Case "UNDERLINE"
' If the MixedState property is True set it to False.
If IsNull(RichTextBox1.SelUnderline) = True Then
' Code to run when selection is mixed.
RichTextBox1.SelUnderline = False
ElseIf RichTextBox1.SelUnderline = False Then
' Code to run when selection is not Underlined to toggle SelUnderlined property to True.
RichTextBox1.SelUnderline = Abs(RichTextBox1.SelUnderline) - 1
End If
End Select
End Sub