How to span function call params across multiple lines?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sean.gilbertson@gmail.com

    How to span function call params across multiple lines?

    How do I do this in VB.NET?

    ---------------------------------------------------

    SomeSubOrFuncCa ll("param 1",
    "param 2",
    "param 3")

    ---------------------------------------------------

    Right now, this is a syntax error. I thought by adding backslashes at
    the ends of the lines it would work, but alas it does not.

    Thanks :-)
    Sean

  • Chris Dunaway

    #2
    Re: How to span function call params across multiple lines?

    On Feb 19, 3:59 pm, sean.gilbert... @gmail.com wrote:
    How do I do this in VB.NET?
    >
    ---------------------------------------------------
    >
    SomeSubOrFuncCa ll("param 1",
    "param 2",
    "param 3")
    >
    ---------------------------------------------------
    >
    Right now, this is a syntax error. I thought by adding backslashes at
    the ends of the lines it would work, but alas it does not.
    >
    Thanks :-)
    Sean
    SomeSubOrFuncCa ll("param 1", _
    "param 2", _
    "param 3")


    Comment

    • Spam Catcher

      #3
      Re: How to span function call params across multiple lines?

      sean.gilbertson @gmail.com wrote in news:1171922389 .523507.309510
      @j27g2000cwj.go oglegroups.com:
      SomeSubOrFuncCa ll("param 1", _
      "param 2", _
      "param 3")

      Use the underscore/

      Comment

      • Armin Zingler

        #4
        Re: How to span function call params across multiple lines?

        <sean.gilbertso n@gmail.comschr ieb
        How do I do this in VB.NET?
        >
        ---------------------------------------------------
        >
        SomeSubOrFuncCa ll("param 1",
        "param 2",
        "param 3")
        >
        ---------------------------------------------------
        >
        Right now, this is a syntax error. I thought by adding backslashes
        at the ends of the lines it would work, but alas it does not.

        SomeSubOrFuncCa ll("param 1", _
        "param 2", _
        "param 3")


        Armin

        Comment

        • Martin

          #5
          Re: How to span function call params across multiple lines?

          In addition to what others have posted, I found that you need a space before
          the underscore for it to work.

          HTH

          Martin

          <sean.gilbertso n@gmail.comwrot e in message
          news:1171922389 .523507.309510@ j27g2000cwj.goo glegroups.com.. .
          How do I do this in VB.NET?
          >
          ---------------------------------------------------
          >
          SomeSubOrFuncCa ll("param 1",
          "param 2",
          "param 3")
          >
          ---------------------------------------------------
          >
          Right now, this is a syntax error. I thought by adding backslashes at
          the ends of the lines it would work, but alas it does not.
          >
          Thanks :-)
          Sean
          >

          Comment

          • sean.gilbertson@gmail.com

            #6
            Re: How to span function call params across multiple lines?

            On Feb 19, 3:59 pm, sean.gilbert... @gmail.com wrote:
            How do I do this in VB.NET?
            >
            ---------------------------------------------------
            >
            SomeSubOrFuncCa ll("param 1",
            "param 2",
            "param 3")
            >
            ---------------------------------------------------
            >
            Right now, this is a syntax error. I thought by adding backslashes at
            the ends of the lines it would work, but alas it does not.
            >
            Thanks :-)
            Sean
            Thanks everyone!! You SET ME STRAIGHT.

            Take care!
            Sean

            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: How to span function call params across multiple lines?

              <sean.gilbertso n@gmail.comschr ieb:
              How do I do this in VB.NET?
              >
              ---------------------------------------------------
              >
              SomeSubOrFuncCa ll("param 1",
              "param 2",
              "param 3")
              >
              ---------------------------------------------------
              >
              Right now, this is a syntax error. I thought by adding backslashes at
              the ends of the lines it would work, but alas it does not.
              Use space-underscore at the end of the line:

              \\\
              SomeSubOrFuncCa ll( _
              "param 1", _
              "param 2", _
              "param 3" _
              )
              ///

              --
              M S Herfried K. Wagner
              M V P <URL:http://dotnet.mvps.org/>
              V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

              Comment

              • Cor Ligthert [MVP]

                #8
                Re: How to span function call params across multiple lines?

                Herfried,

                I know that you like it in Austria the real ones and this is even a 5times
                one, however please set it off.

                Cor

                "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atschr eef in bericht
                news:uuZ293IVHH A.600@TK2MSFTNG P05.phx.gbl...
                <sean.gilbertso n@gmail.comschr ieb:
                >How do I do this in VB.NET?
                >>
                >---------------------------------------------------
                >>
                >SomeSubOrFuncC all("param 1",
                >"param 2",
                >"param 3")
                >>
                >---------------------------------------------------
                >>
                >Right now, this is a syntax error. I thought by adding backslashes at
                >the ends of the lines it would work, but alas it does not.
                >
                Use space-underscore at the end of the line:
                >
                \\\
                SomeSubOrFuncCa ll( _
                "param 1", _
                "param 2", _
                "param 3" _
                )
                ///
                >
                --
                M S Herfried K. Wagner
                M V P <URL:http://dotnet.mvps.org/>
                V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                Comment

                • Herfried K. Wagner [MVP]

                  #9
                  Re: How to span function call params across multiple lines?

                  "Cor Ligthert [MVP]" <notmyfirstname @planet.nlschri eb:
                  I know that you like it in Austria the real ones and this is even a 5times
                  one, however please set it off.
                  I wanted to show my preferred /style/ of formatting longer procedure calls.

                  --
                  M S Herfried K. Wagner
                  M V P <URL:http://dotnet.mvps.org/>
                  V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                  Comment

                  • Cor Ligthert [MVP]

                    #10
                    Re: How to span function call params across multiple lines?

                    OK,

                    Discussion :-)

                    What is in your opinion the advantage from that?

                    Cor

                    "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atschr eef in bericht
                    news:u08$bDPVHH A.192@TK2MSFTNG P04.phx.gbl...
                    "Cor Ligthert [MVP]" <notmyfirstname @planet.nlschri eb:
                    >I know that you like it in Austria the real ones and this is even a
                    >5times one, however please set it off.
                    >
                    I wanted to show my preferred /style/ of formatting longer procedure
                    calls.
                    >
                    --
                    M S Herfried K. Wagner
                    M V P <URL:http://dotnet.mvps.org/>
                    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                    Comment

                    • Herfried K. Wagner [MVP]

                      #11
                      Re: How to span function call params across multiple lines?

                      "Cor Ligthert [MVP]" <notmyfirstname @planet.nlschri eb:
                      OK,
                      >
                      Discussion :-)
                      >
                      What is in your opinion the advantage from that?
                      Readability.

                      --
                      M S Herfried K. Wagner
                      M V P <URL:http://dotnet.mvps.org/>
                      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                      Comment

                      • Cor Ligthert [MVP]

                        #12
                        Re: How to span function call params across multiple lines?

                        \Readability.
                        \\
                        SomeSubOrFuncCa ll( _
                        "param 1", _
                        "param 2", _
                        "param 3" _
                        )
                        ///

                        I don't think that it does that for me. Especialy the last blank underscore
                        which does suggest that there is more is in my idea confusing.

                        Cor

                        "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atschr eef in bericht
                        news:%23JYYazRV HHA.192@TK2MSFT NGP04.phx.gbl.. .
                        "Cor Ligthert [MVP]" <notmyfirstname @planet.nlschri eb:
                        >OK,
                        >>
                        >Discussion :-)
                        >>
                        >What is in your opinion the advantage from that?
                        >
                        Readability.
                        >
                        --
                        M S Herfried K. Wagner
                        M V P <URL:http://dotnet.mvps.org/>
                        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                        Comment

                        • Phill W.

                          #13
                          Re: How to span function call params across multiple lines?

                          Cor Ligthert [MVP] wrote:
                          \Readability.
                          \\
                          SomeSubOrFuncCa ll( _
                          "param 1", _
                          "param 2", _
                          "param 3" _
                          )
                          ///
                          >
                          I don't think that it does that for me. Especialy the last blank underscore
                          which does suggest that there is more is in my idea confusing.
                          There /is/ more - the closing bracket. :-)

                          Confusing? Perhaps, but it makes it easier to manipulate the number of
                          arguments as [and when] you add or remove them. It's far easier to add
                          and remove entire lines than to fiddle about in the middle of them,
                          especially if said line is four times wider than your screen.

                          Also, I think Herfried's example is oversimplified - I frequently find
                          that each argument to a method can /itself/ span much of a page, so
                          separating each into its own line adds to the clarity.

                          Note: I /don't/ do this for /every/ function call!
                          Typically, I'll break it down as above as soon as the [single] line
                          starts nearing the edge of my code window.

                          Regards,
                          Phill W.

                          Comment

                          • Herfried K. Wagner [MVP]

                            #14
                            Re: How to span function call params across multiple lines?

                            "Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kschrieb:
                            >\Readability .
                            >\\
                            >SomeSubOrFuncC all( _
                            > "param 1", _
                            > "param 2", _
                            > "param 3" _
                            >)
                            >///
                            >>
                            >I don't think that it does that for me. Especialy the last blank
                            >underscore which does suggest that there is more is in my idea confusing.
                            >
                            There /is/ more - the closing bracket. :-)
                            >
                            Confusing? Perhaps, but it makes it easier to manipulate the number of
                            arguments as [and when] you add or remove them. It's far easier to add
                            and remove entire lines than to fiddle about in the middle of them,
                            especially if said line is four times wider than your screen.
                            >
                            Also, I think Herfried's example is oversimplified - I frequently find
                            that each argument to a method can /itself/ span much of a page, so
                            separating each into its own line adds to the clarity.
                            That's true. In this cases I nest multi-line calls (again a simple
                            example):

                            \\\
                            Bla( _
                            Param1, _
                            Foo( _
                            Param1, _
                            Param2 _
                            ), _
                            Param3 _
                            )
                            ///
                            Note: I /don't/ do this for /every/ function call!
                            Typically, I'll break it down as above as soon as the [single] line starts
                            nearing the edge of my code window.
                            That's how I am doing it too.

                            --
                            M S Herfried K. Wagner
                            M V P <URL:http://dotnet.mvps.org/>
                            V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

                            Comment

                            • Zytan

                              #15
                              Re: How to span function call params across multiple lines?

                              \\\
                              Bla( _
                              Param1, _
                              Foo( _
                              Param1, _
                              Param2 _
                              ), _
                              Param3 _
                              )
                              ///
                              I agree with Herfried. Unfortunately VB's autoformatter doesn't work
                              with _. It left justifies them at first. And then if you mess with
                              the previous line, it'll push them even further left (yes, it
                              reformats the line you AREN'T messing with)!

                              I wish it had extra options, kinda like C# does, for formatting.
                              Would be cool.

                              Zytan

                              Comment

                              Working...