3

I know that I can use a With statement to make repeated references to a single object:

With myObj
  .StringProperty = ""
  .BooleanProperty = False
End With

However, what I want to know is: is there a shorthand for referring to the original object in the With statement? In the above example, can I refer to myObj without explicitly typing myObj as I'm already working with it.

Mark Hurd
  • 10,665
  • 10
  • 68
  • 101
geekchic
  • 1,526
  • 1
  • 11
  • 21

1 Answers1

4

No you can't, but it wouldn't mean much anyway. With just sets the default scope to the object expression that follows it. If you need a reference to the object this doesn't help unless the object is one of the very few that has a .Self property, which is quite rare.

Bob77
  • 13,167
  • 1
  • 29
  • 37
  • +1. There are a lot of objects that would allow a structure like `.Child.Parent`, but again that's not particularly useful. – Daniel Dec 21 '12 at 16:10
  • I suspected as much, but just wanted to make sure. – geekchic Dec 21 '12 at 16:24
  • There are times when it might be handy if you could use `.` to pick up the object reference, but it just doesn't work that way. – Bob77 Dec 21 '12 at 16:46
  • 3
    I miss this feature, esp. when doing `With New cMyClass ... End With` – wqw Dec 22 '12 at 10:30