vblang icon indicating copy to clipboard operation
vblang copied to clipboard

Allow With Enum, and With Class that has some shared members

Open VBAndCs opened this issue 4 years ago • 1 comments

I have a class named MyFlag with some static methods (and other non-static methods). Suppose I am using this code:

Dim flag = MyFlag.X
flag += MyFlag.Y
flag = flag Xor MyFlag.Z

I tried to do this:

With MyFlag
   Dim flag =.X
   flag +=.Y
   flag = flag Xor .Z
End With

But got the error:

'MyFlag' is a class type and cannot be used as an expression.

So, I suggest to allow using classes that have some Static members in With block. This should also include enums.

VBAndCs avatar Nov 02 '20 13:11 VBAndCs

Another example:

With Console
    .Clear()
    .Title = "foo"
    .WriteLine("bar")
End With

However, see #162 -- not sure if I'd rather see this or that (or both)

gilfusion avatar Nov 02 '20 17:11 gilfusion