locked
Command line too long

    Question

  • How does one break up a long command line so that it shows on multiple lines.

    myString =

    "Name....................Hydrogen"& vbNewLine & "Symbol..................H"& vbNewLine & "Atomic Number...........1"& vbNewLine & "Atomic Weight...........1.00794"& vbNewLine & "Molecular Weitght..H2...2.016"& vbNewLine & "Melting Point...........-259.34 C"& vbNewLine & "Boiling Point...........-252.87 C"& vbNewLine & "Density.................0.082 g/l"& vbNewLine & "Specific Gravity........70.8 (liquid, -253 C)"& vbNewLine & "Specific Gravity........70.6 (Solid,  -262 C)"& vbNewLine & "Oxidation State.........+/- 1"& vbNewLine & "Electron Configuration 1s1"& vbNewLine & "Electronegativity...of H.. 2.20"& vbNewLine & "Electron affinity...of H.. 0.754593"& vbNewLine & "Electron affinity...of D.. 0.754195"& vbNewLine & "Electron affinity...of T.. 0.754090"

    Tuesday, March 06, 2012 8:48 PM

Answers

  • You can use the " _" for line continuation:

     myString = "abc " _
        & "def" _
        & "ghi"

    Or you can use a Stringbuilder:

      dim sb as new System.Text.Stringbuilder()

      sb.appendline("abc")
      sb.appendline("def")
      sb.appendline("ghi")

      myString = sb.ToString()


    Armin

    • Proposed as answer by Reed Copsey, JrMVP Tuesday, March 06, 2012 9:00 PM
    • Marked as answer by Plasman Tuesday, March 06, 2012 9:12 PM
    Tuesday, March 06, 2012 8:57 PM

All replies

  • You can use the " _" for line continuation:

     myString = "abc " _
        & "def" _
        & "ghi"

    Or you can use a Stringbuilder:

      dim sb as new System.Text.Stringbuilder()

      sb.appendline("abc")
      sb.appendline("def")
      sb.appendline("ghi")

      myString = sb.ToString()


    Armin

    • Proposed as answer by Reed Copsey, JrMVP Tuesday, March 06, 2012 9:00 PM
    • Marked as answer by Plasman Tuesday, March 06, 2012 9:12 PM
    Tuesday, March 06, 2012 8:57 PM
  • Thank you.

    Tuesday, March 06, 2012 9:13 PM