none
Please - Need Help with Word form Listbox problem RRS feed

  • Question

  • I am creating a listbox for an online Word form I am creating. I am using the legacy list box as I have about 70 records that I need to include in this listbox. I'm in the Visual Basic area and learned my "line was too long" so I researched that I could add "& _" to break up the lines. That worked great. However, now the record at the end of the line before "& _" shows up on the same line as the record on the next line, when I run the code. How can I fix this. I have searched and searched and can't find it.

    Example:

    ListBox1.List = Array("Apples", "Oranges", "Watermelon", "Kiwi", "Bananas" & _
    "Limes", "Lemons", "Grapes", "Cherries", "Cantelope", "Blackberry")

    After I run and go back to see how it works in the Word form, here is how it shows up in the listbox:

    Apples

    Oranges

    Watermelon

    Kiwi

    BananasLimes (HERE LIES THE PROBLEM. How do I get "Limes" to go to the next line in the Listbox?)

    Lemons

    Grapes

    etc.

    I really appreciate your help. I'm spending way too much time trying to figure this out.

    Thanks,

    Lauren

    Wednesday, March 5, 2014 11:40 PM

Answers

  • Try:

    ListBox1.List = Array("Apples", "Oranges", "Watermelon", "Kiwi", "Bananas",  _
    "Limes", "Lemons", "Grapes", "Cherries", "Cantelope", "Blackberry")

    (note the comma after "Bananas")


    Cheers
    Paul Edstein
    [MS MVP - Word]


    Thursday, March 6, 2014 3:33 AM
  • Sorry, you should omit the & as well.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by lawoman728 Thursday, March 6, 2014 10:13 PM
    Thursday, March 6, 2014 8:33 PM

All replies

  • Try:

    ListBox1.List = Array("Apples", "Oranges", "Watermelon", "Kiwi", "Bananas",  _
    "Limes", "Lemons", "Grapes", "Cherries", "Cantelope", "Blackberry")

    (note the comma after "Bananas")


    Cheers
    Paul Edstein
    [MS MVP - Word]


    Thursday, March 6, 2014 3:33 AM
  • Thanks Paul. When I add the comma after "Bananas" I get the following error:

    Compile Error:

    Expected: Expression

    and the & symbol is highlighted.

    Any other suggestions? Please.

    Thursday, March 6, 2014 1:38 PM
  • Sorry, you should omit the & as well.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by lawoman728 Thursday, March 6, 2014 10:13 PM
    Thursday, March 6, 2014 8:33 PM
  • Perfect - that was it. THANK YOU SO MUCH!
    • Marked as answer by lawoman728 Thursday, March 6, 2014 10:13 PM
    • Unmarked as answer by lawoman728 Thursday, March 6, 2014 10:13 PM
    Thursday, March 6, 2014 10:13 PM