Results 1 to 11 of 11

Thread: [RESOLVED] General VB problem

  1. #1

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Resolved [RESOLVED] General VB problem

    This is a general VB problem. With this code from User Control:
    Code:
    With Extender.Parent.Controls(Extender.Name).Item(0)
        .property = value
    End With
    ... nothing happens (.property is the same as before). But this:
    Code:
    Extender.Parent.Controls(Extender.Name).Item(0).property = value
    ... works.

    Am i missing something?

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: General VB problem

    Your probably nesting With statements. Keep it at one level.

  3. #3

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: General VB problem

    Quote Originally Posted by leinad31
    Your probably nesting With statements. Keep it at one level.
    No. It's the only one. There's no nesting at all.

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: General VB problem

    I thought there has always been a problem with highly nested expressions.. as in, theres 5 dots in your statement.. I think the maximum is 3? I'm sure theres a service pack for that though.. can't remember.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: General VB problem

    Have you try this:
    Code:
    (Set) Item = Extender.Parent.Controls(Extender.Name).Item(0)
    With Item
        .property = value
    End With
    Does this work?

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: General VB problem

    some things just don't work in with blocks
    take with printer for example
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: General VB problem

    Quote Originally Posted by anhn
    Have you try this...
    How can it be an Item, when it's a property?
    Quote Originally Posted by westconn1
    some things just don't work in with blocks...
    I'm not trying to get it to work, cause i'm quite satisfied with my current solution. I was just wondering, why With block causes the problem.

  8. #8
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: General VB problem

    try this

    With Extender.Parent.Controls(Extender.Name)
    Item(0).property = value
    End With
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  9. #9

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: General VB problem

    Quote Originally Posted by Pasvorto
    try this

    With Extender.Parent.Controls(Extender.Name)
    Item(0).property = value
    End With
    OK. This works Why's so?

  10. #10
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: General VB problem

    I think the index is screwing it up
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  11. #11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width