RunTime 91 - Object variable or With variable not set 
Author Message
 RunTime 91 - Object variable or With variable not set

I get runtime 91 - object variable or with variable not set

Dim wTextBox As RichTextBox
'With wTextBox
wTextBox.Text = "Field " + wField
wTextBox.Left = CSng(wX)
wTextBox.Top = CSng(wY)
wTextBox.Width = CSng(wWidth)
wTextBox.Height = CSng(wHeight)

when I debug, it says that wTextBox is (nothing)  Am I doing something wrong?
I want to create the wTextBox as part of TheForm (as form) at run-time.

Can anyone give me a few tips?

I had tried setting the parent to TheForm by  wTextBox.parent = TheForm but
that said "invalid use of property"

If I need to post more code, I can  Thanks in advance.

**AKBishop**

..still resisting the Computer {*filter*}s Anonymous meetings



Fri, 22 Dec 2000 03:00:00 GMT  
 RunTime 91 - Object variable or With variable not set

Quote:

>I get runtime 91 - object variable or with variable not set

>Dim wTextBox As RichTextBox
>'With wTextBox
>wTextBox.Text = "Field " + wField
>wTextBox.Left = CSng(wX)
>wTextBox.Top = CSng(wY)
>wTextBox.Width = CSng(wWidth)
>wTextBox.Height = CSng(wHeight)

The WITH block should look like

        WITH wTextBox
                .Text = "Field " + wField
                .Left = CSng(wX)
                .Top = CSng(wY)
                .Width = CSng(wWidth)
                .Height = CSng(wHeight)
        END WITH



Fri, 22 Dec 2000 03:00:00 GMT  
 RunTime 91 - Object variable or With variable not set

I don't know if I've understtod your question correctly.

As far as I know, VB will not let you create controls at run time. You can only
create objects.
You can create controls at run time only if you have created one at design time
and made it part of a control array.

Say you need three text boxes. You have to create the first one text1(0) and give
it an index =0.
Then you can create the other two at run time
load text1(1)
text1(1).visible = true

and the same with the third member. You need to set the left, top, height and
width properties yourself in code.

For more information, search for Control arrays in Online help.
Hope this helps....

Quote:

> I get runtime 91 - object variable or with variable not set

> Dim wTextBox As RichTextBox
> 'With wTextBox
> wTextBox.Text = "Field " + wField
> wTextBox.Left = CSng(wX)
> wTextBox.Top = CSng(wY)
> wTextBox.Width = CSng(wWidth)
> wTextBox.Height = CSng(wHeight)

> when I debug, it says that wTextBox is (nothing)  Am I doing something wrong?
> I want to create the wTextBox as part of TheForm (as form) at run-time.

> Can anyone give me a few tips?

> I had tried setting the parent to TheForm by  wTextBox.parent = TheForm but
> that said "invalid use of property"

> If I need to post more code, I can  Thanks in advance.

> **AKBishop**

> ..still resisting the Computer {*filter*}s Anonymous meetings



Fri, 22 Dec 2000 03:00:00 GMT  
 RunTime 91 - Object variable or With variable not set


Quote:
Harrison) writes:
>The WITH block should look like

>        WITH wTextBox
>                .Text = "Field " + wField
>                .Left = CSng(wX)
>                .Top = CSng(wY)
>                .Width = CSng(wWidth)
>                .Height = CSng(wHeight)
>        END WITH

sorry, the with wTextBox in my code was commented out.  But I tried changing it
and I get the exact same error.

thanks for trying, though.  i appreciate it.

**AKBishop**

..still resisting the Computer {*filter*}s Anonymous meetings



Fri, 22 Dec 2000 03:00:00 GMT  
 RunTime 91 - Object variable or With variable not set


Quote:
>I get runtime 91 - object variable or with variable not set

>Dim wTextBox As RichTextBox
>'With wTextBox
>wTextBox.Text = "Field " + wField
>wTextBox.Left = CSng(wX)
>wTextBox.Top = CSng(wY)
>wTextBox.Width = CSng(wWidth)
>wTextBox.Height = CSng(wHeight)

>when I debug, it says that wTextBox is (nothing)  Am I doing something
wrong?
>I want to create the wTextBox as part of TheForm (as form) at run-time.

You can't create new controls at runtime, only load instances of existing
indexed controls.

You have to assign wTextBox to a control before you manipulate it, else
you'll get that error.  Say something like "set wTextBox =
form1.myrichtextbox" before you manipulate it.  If needs be, it can be
invisible, then turned visible at that point.

--Cindy



Fri, 22 Dec 2000 03:00:00 GMT  
 RunTime 91 - Object variable or With variable not set
Dim wTextBox As NEW RichTextBox
'With wTextBox
wTextBox.Text = "Field " + wField
wTextBox.Left = CSng(wX)
wTextBox.Top = CSng(wY)
wTextBox.Width = CSng(wWidth)
wTextBox.Height = CSng(wHeight)


Quote:
>I get runtime 91 - object variable or with variable not set

>Dim wTextBox As RichTextBox
>'With wTextBox
>wTextBox.Text = "Field " + wField
>wTextBox.Left = CSng(wX)
>wTextBox.Top = CSng(wY)
>wTextBox.Width = CSng(wWidth)
>wTextBox.Height = CSng(wHeight)

>when I debug, it says that wTextBox is (nothing)  Am I doing something
wrong?
>I want to create the wTextBox as part of TheForm (as form) at run-time.

>Can anyone give me a few tips?

>I had tried setting the parent to TheForm by  wTextBox.parent = TheForm but
>that said "invalid use of property"

>If I need to post more code, I can  Thanks in advance.

>**AKBishop**

>..still resisting the Computer {*filter*}s Anonymous meetings



Sat, 30 Dec 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Runtime error 91/Object variable or With block variable not set problems

2. runtime error: 91 Object variable or with block variable not set

3. Object variable or With block variable not set (Error 91)

4. error 91 Object Variable o on with block variable is not set

5. Object variable or With block variable not set (Error 91) Please Help

6. Run Time Error 91: Object variable or With Block variable not set

7. VB 5.0 - Error:91 Object Variable Or With Block Variable Not Set

8. Object variable or With block variable not set (Error 91)

9. Error 91 Object variable or With-Block, variable not set

10. Debugging COM+ Componets -- Runtime error 91- Object variable or with block not set

11. Runtime error 91: Object or with block variable not defined

12. Error 91 - Object Variable Not Set **** Need Help

 

 
Powered by phpBB® Forum Software