How to access the object itself in With … End With

后端 未结 4 1044
情歌与酒
情歌与酒 2020-12-03 17:32

Some code to illustrate my question:

With Test.AnObject

    .Something = 1337
    .AnotherThing = \"Hello\"

    \'\'// why can\'t I do this to pass the obj         


        
4条回答
  •  时光取名叫无心
    2020-12-03 18:21

    I suspect you'll have to repeat yourself. If the expression (to get the object) is expensive, then perhaps drop it into a variable first, and either use that variable in the With, or drop the With completely:

    tmp = Test.AnObject;
    tmp.Something = 1337;
    ...
    Test2.Subroutine(tmp);
    

提交回复
热议问题