Bryan A. Bentz February 2016

In VB.net is there an option to force generation of the counter variable in the "Next" statement?

Visual Basic .net automatically inserts a "Next" statement when you enter a "For" statement; e.g., if I type:

For i as integer = 1 to 10

a Next will automatically be inserted, so that the code looks like:

For i as integer = 1 to 10

Next

It is optional to put the counter variable ("i" in the above) in the Next statement, so that it would read:

Next i

I'd really like to make this the default, as it really helps when one has nested For statements. I can't find anything in the Visual Studio settings to do this; maybe it's partly buried somewhere in Intellisense. I thought perhaps someone out there has already figured this out.

Answers


gmiley February 2016

You will want to modify the .snippet file associated with the pattern. For the one you are looking for it is, by default:

VisualStudioInstallDirectory\VB\Snippets\1033\common code patterns\conditionals and loops\ForEachNext.snippet

You can also track down the exact location by looking in

Tools > Code Snippets Manager..., select Visual Basic for the language and browse to Code Patterns - If, For Each, Try Catch, Property, etc - the file location will be listed there.

Post Status

Asked in February 2016
Viewed 2,648 times
Voted 11
Answered 1 times

Search




Leave an answer