VB.NET: can a function be divided into sections?

Is it possible to divide a function into sections, something like this?

Function myFunc

  Section
    Dim i As Integer = 0
    ...
  End Section

  Section
    Dim i As Integer = 0
    ...
  End Section

End Function

I understand that this can be done with

If True Then
  Dim i As Integer = 0
  ...
End If

but it seems like a hack

Am I going about it wrong?

+3
source share
2 answers

I would recommend reorganizing your "Sections" into separate functions or subprograms and naming them accordingly. The fact that you want this separate one seems to emphasize the possibility of refactoring ....

+3
source

It looks like you need to split your function into ... more functions.

, . . , , .

, . CreateDatabaseConnection. CreateDatabaseConnectionAndSelectContacts (.. "" ), .

+4

All Articles