Nasir
Nasir

Reputation: 11401

Function call spanning multiple lines in VB.NET

I have a C# function call which looks something like this:

var res = function ("arg1",   // argument# 1
                    "arg2",   // argument# 2
                    "arg3"    // argument# 3
                   );

the list of arguments is around 25 or so. It's a Web Services function, which I have no control over.

I'm trying to port it to VB.NET for another application and was wondering if VB.NET will let me call a function in this manner (with comments, if possible)?

Upvotes: 3

Views: 5211

Answers (4)

user1228
user1228

Reputation:

I believe you desire the _ line continuation character.

Upvotes: 0

Konrad Rudolph
Konrad Rudolph

Reputation: 545618

FYI, the next version of VB will let you write the call like this:

Dim res = function("arg1",
                   "arg2",
                   "arg3"
                  )

I.e. without underscores to continue the lines.

Upvotes: 7

Doogie
Doogie

Reputation: 815

Dim res = function("arg1", _
                  "arg2", _
                  "arg3" _
                    )

Will work, however you can't add comments to each line, as the _ character has to be the last character on the line.

Upvotes: 12

Achilles
Achilles

Reputation: 11299

It will not. You can use the built-in XML comments to add comments to the function declaration. In VS simply type "'''" above the function and it will automatically generate a comment body for you to fill out.

If you want to list your parameters on a function call in that way, you can use the line continuation character "_" following each parameter to list the function parameters.

Upvotes: 0

Related Questions