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

[Proposal] Allow Select Case to compare Object references #568

Open
VBAndCs opened this issue Sep 14, 2020 · 3 comments
Open

[Proposal] Allow Select Case to compare Object references #568

VBAndCs opened this issue Sep 14, 2020 · 3 comments

Comments

@VBAndCs
Copy link

VBAndCs commented Sep 14, 2020

This Code gives me a runtime exception, as it is assumed to use = in comparing the objects:

Select Case e.OriginalSource
   Case Me, Me.TexTBox
      cmb.IsDropDownOpen = Not cmb.IsDropDownOpen
End Select

So, this is Ok, but at least allow us to use Is. It is already used in some cases like Case Is < 10, but the next code is not accepted, and I think it should be:

Select Case e.OriginalSource
   Case Is Me, Is Me.TexTBox
      cmb.IsDropDownOpen = Not cmb.IsDropDownOpen
End Select

The only valid way is:

Select Case e.OriginalSource.GetType
  Case Me.GetType, Me.TexTBox.GetType
     cmb.IsDropDownOpen = Not cmb.IsDropDownOpen
End Select

Which is verbose and involving calling three methods!

@hartmair
Copy link

This problem is similar to #541. I'd be happy to see all this flavours of type matching be covered by a general pattern matching syntax like #367 so far.

@VBAndCs
Copy link
Author

VBAndCs commented Sep 17, 2020

There is a difference. There I was comparing types, but here I am comparing references. In my use case, I could use the types instead of references because I am responding to an event that travels a specific route. This will not always be the case.

@AdamSpeight2008
Copy link
Contributor

Select Case has other constructions.

Select Case True
       Case e.OriginalSource Is Me         : cmb.IsDropDownOpen = Not cmb.IsDropDownOpen
       Case e.OriginalSource Is Me.TexTBox : cmb.IsDropDownOpen = Not cmb.IsDropDownOpen
       Case Else Case Me, Me.TexTBox
End Select

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

No branches or pull requests

3 participants