[Solved] Curious about MessageBox and multi-line input

Welcome Forums General PowerShell Q&A [Solved] Curious about MessageBox and multi-line input

Viewing 3 reply threads
  • Author
    Posts
    • #260574
      Participant
      Topics: 29
      Replies: 29
      Points: 177
      Rank: Participant

      I am working on a script that is something along the lines of a practice test GUI, with questions and answers pulled at random from a SQLite db. Everything works as expected, I just noticed one oddity and was curious if anyone knows why. Some of the questions are a (Choose the best two/three). In the db, the multiple answers are a single string, comma-separated. If the user selects the wrong options, I throw a message box, something like this:

      This works just fine, however I notice the first answer line is in-line, while the second is automatically indented by one or two spaces. I’ve tried formatting a couple different ways (only r, onlyn, etc.), but see the same behavior each time. Any idea why this happens?

      • This topic was modified 3 weeks, 3 days ago by Jeremiah Logan.
      • This topic was modified 3 weeks, 3 days ago by Jeremiah Logan.
      • This topic was modified 3 weeks ago by grokkit.
      • This topic was modified 3 weeks ago by grokkit.
      • This topic was modified 2 weeks, 6 days ago by Jeremiah Logan.
    • #260955
      Participant
      Topics: 25
      Replies: 197
      Points: 718
      Helping Hand
      Rank: Major Contributor

      try using “`r`n”

      • This reply was modified 3 weeks ago by grokkit.
    • #261033
      Participant
      Topics: 8
      Replies: 617
      Points: 2,393
      Helping Hand
      Rank: Community Hero

      The issue is you are adding a space which is not needed as the next string will be on a new line. So you are literally saying

      Line1
      <space>Line2
      <space>Line3

      Maybe this demo will help clarify.

      Demo

    • #261290
      Participant
      Topics: 29
      Replies: 29
      Points: 177
      Rank: Participant

      Thanks, perhaps staring at it too long, I missed the space after the second carriage return.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.