简体   繁体   中英

visual basic in visual studio 2017 intellisense if statement with parentheses broken

Since updating to Visual Studio 2017 I have observed unwanted behavior when constructing if statements, in that intellisense doesn't recognize variable names when I attempt to surround the clause in parenthesis. Consider the following incomplete code:

class AnythingClass
    ....
end class

public Sub doSomething()
  Dim anythingInstance as new AnythingClass
  if anyt

When typing code in this manner, the instance "anythingInstance" will be suggested by autocomplete. However, if I open parentasis when starting the if clause as below

class AnythingClass
    ....
end class

public Sub doSomething()
  Dim anythingInstance as new AnythingClass
  if (anyt

then the declared variable will not show in the autocomplete suggestions. The class name AnythingClass will show up in the suggestions, but not the instance

UPDATE

(edit) THIS ANALYSIS IS INCORRECT , please see my answer for details as to why

I have tried creating a brand new project and get the expected behavior. So this only appears to happen in projects that have previously been upgraded from older versions of visual studio.

I have attached a couple of screenshots for the skeptics!

无括号工作

括号破损

Based on comments from @Maciej Los and @TnTinMn, I have managed to piece together the issue.

If you write the code as:

IF (an...

with a whitespace between the IF and the arguments, Then autocomplete appears to treat it as an If statement and will display instance variables. However if you write the code as

IF(an...

with no whitespace, autocomplete appears to treat it as the If operator and not show declared instances. Quite why this is the case, I don't know. My original analysis of there being a difference between new projects and previously imported ones was incorrect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM