Results 1 to 14 of 14

Thread: multi line testing

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Question multi line testing

    I have an application where the user types text into a multiline text box and it is added to a list box.

    One major problem is that if the user types more than can fit in the list box, the text just continues off the end of the list box.

    Is there a way i can write each line of the text box to a seperate line in the list box??

    Cheers

    GTJ

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: multi line testing

    May I ask the purpose for writing the text to a listbox?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: multi line testing

    to show history of what they have typed..... but can you help with the problem???

  4. #4
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: multi line testing

    Why not just add a scroll bar to the list box?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: multi line testing

    you can't add a horizontal scrollbar?? it also looks neater to have a new line per new line in the text box...

  6. #6
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: multi line testing

    You could add the line to the list box each time the user enters a carriage return (vbcrlf) and clear the text box for the next line.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: multi line testing

    yes, but a text box automatically starts a new line when the user reaches the right side??

  8. #8
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: multi line testing

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim nLimit As Long, s As String
    3.     nLimit = 50     '<-- change this as per the width of your listbox
    4.     s = Text1.Text
    5.     Do While s <> ""
    6.         List1.AddItem Left(s, nLimit)
    7.         s = Mid(s, nLimit + 1)
    8.     Loop
    9. End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  9. #9
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: multi line testing

    Quote Originally Posted by Pasvorto
    You could add the line to the list box each time the user enters a carriage return (vbcrlf) and clear the text box for the next line.
    What if the user never presses Enter key but types a very long sentence? (assuming only vertical scroll bar is enabled)
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: multi line testing

    You could use the .ToolTipText to display the field when they click on a listitem.

  11. #11
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: multi line testing

    Add each keystoke to the listbox as it as typed into the text box...

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: multi line testing

    how would that help my problem?? the keys would still be entered off the edge of the list box...

  13. #13
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: multi line testing

    I like the earlier thought. Store the keystrokes in a variable until they meet your line limit. Then add them to the listbox and clear the variable to receive new data.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: multi line testing

    ok cool i will try Pradeep1210's method

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width