Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VBA Line Continuation example #3945

Closed
Beakerboy opened this issue Jan 26, 2024 · 3 comments
Closed

VBA Line Continuation example #3945

Beakerboy opened this issue Jan 26, 2024 · 3 comments
Labels

Comments

@Beakerboy
Copy link
Contributor

An example file was added by @SSlinky some time ago. It contains a few With statements that include line continuation. I've tested some similar statements and they fail in MS VBA 7.1:
If i create a module that contains a function:

Function foo(B As Range)
    With B _
        .ID = "2"
    End With
    foo = B.ID
End Function

I receive an error: "With object must be user-defined type, Object, or Variant"

There is the same error for:

Function foo(B As Range)
    With B. _
        ID = "2"
    End With
    foo = B.ID
End Function

Both of these examples are listed in example7linecontinuation.bas, and I feel they should be removed. Is there a way to specify a file as containing counter-examples, and must fail?

@Beakerboy
Copy link
Contributor Author

Beakerboy commented Jan 26, 2024

I propose replacing it with something like:

Function _
foo( _
B _
    As _
    Range _
    )
    With _
    B
        .ID _
        = _
        "2"
    End _
        With
    foo = B. _
        ID
End _
    Function

@KvanTTT KvanTTT added the vba label Jan 27, 2024
@SSlinky
Copy link
Contributor

SSlinky commented Feb 5, 2024

I know this has been closed, but for completeness, neither of those examples are in the file. Only the With opening and closing blocks are included, e.g.:

With A _
    .B
End With

Is equivalent to:

With A.B
End With

The ID property, and assigning values to it, were not part of the examples.

@Beakerboy
Copy link
Contributor Author

Beakerboy commented Feb 5, 2024

I know, that’s why I closed it. I was messing around with all kinds of variations of line continuation and line breaks and mixed up some of my comparisons.

in case you’re interested, I’ve remade the grammar to match the VBA 7.1 specification. I’ve found a bunch of bugs in the official spec, and there are some whitespace bugs in my file still, so it’s a work in progress. Check it out and let me know if you have any advice.
https://github.com/Beakerboy/grammars-v4/tree/patch-7/vba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants