Results 1 to 16 of 16

Thread: [RESOLVED] Inserting lot of characters into multiline textbox is very slow

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Resolved [RESOLVED] Inserting lot of characters into multiline textbox is very slow

    Hi,
    everytime Im putting lot of text (letters, numbers, characters) into multiline textbox - copy, paste (more than 500,000), insertion process in painfully slow and app freezes...
    How can it be speeded up?
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: Inserting lot of characters into multiline textbox is very slow

    Hard to say, without seeing your code.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Inserting lot of characters into multiline textbox is very slow

    Since you mentioned that this was a multiline textbox, my guess would be that the way you are causing it to enter is resulting in the textbox attempting to refresh at least once per line, if not something far worse, like once per character. Either one would certainly kill performance. However, it doesn't HAVE to be that, so we would have to see the code to say more clearly.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Inserting lot of characters into multiline textbox is very slow

    I have created new project just with textbox1 multiline and the problem is still here... it is not related to any code at all. Text that I have does not contains spaces, but I think its irrelevant - it is one big (5 000 000 characters) long string such as FFGGG.8547===ˇˇˇ4522hjguzfu
    Last edited by VB.NET Developer; Nov 10th, 2021 at 04:39 PM.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Inserting lot of characters into multiline textbox is very slow

    Why do you want to display that many characters at once?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Inserting lot of characters into multiline textbox is very slow

    I want to build LTFV - large text file v iewer.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Inserting lot of characters into multiline textbox is very slow

    How are you adding it to the TextBox? That method is what everyone else here has been getting at. Your method makes a big difference.
    If it’s just TextBox1.Text = aVeryLongString, there’s not much you can do about it…

  8. #8
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,393

    Re: Inserting lot of characters into multiline textbox is very slow

    A Large Text File Viewer would not be likely to work as you are trying to do it. No one's monitor can display that many characters at once, and, even if it could, no one can read, scan, or memorize that many characters at once, especially the kind of text in your example. You would display a reasonable amount of text in a text box, then load the next, or previous section of text as needed when they scroll the display or click the Next or Previous button. That eliminates the issue entirely.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Inserting lot of characters into multiline textbox is very slow

    By pasting already copied long text via ctrl+v into textbox.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Inserting lot of characters into multiline textbox is very slow

    Sure, I have some idea to split large text into smaller blocks and load it that way, but Id like to know if it is possible to load a very long string at once.

    I have opened txt file with 6 000 000 characters via notepad without problems and delays - it takes only 5 seconds which is OK.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  11. #11
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,393

    Re: Inserting lot of characters into multiline textbox is very slow

    With Notepad, you are opening text file that is stored on disk. Pasting from the Clipboard is another matter entirely.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Inserting lot of characters into multiline textbox is very slow

    Sure, but I have tried to paste text from clipboard to a blank txt document and it was without delays - only 5 seconds.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Inserting lot of characters into multiline textbox is very slow

    Pasting to RichTextBox solved the issue. But I am interested why its not possible to do that via textbox multiline.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

  14. #14
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Inserting lot of characters into multiline textbox is very slow

    Yeah, I wouldn't really think that copying and pasting would make much difference. It would just be shifting bytes in memory as opposed to reading them from disk...sort of, except that a GB of data is a whole lot, so it might use the swap file.

    I assume, therefore, that the textbox is doing some kind of formatting, possibly due to chunking the text into lines. You might try removing the multiline nature of the textbox and trying that. If the paste then happens smoothly, then it is that multiline chunking that is likely causing the problem.
    My usual boring signature: Nothing

  15. #15
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: Inserting lot of characters into multiline textbox is very slow

    Ah, overlooked the copy/paste comment in the initial post. What did you have the MaxLength property set to, it defaults to 32767. I've never tried to make it higher.

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2018
    Posts
    276

    Re: Inserting lot of characters into multiline textbox is very slow

    @Shaggy Hiker,
    the same situation woith multiline removed.

    @wes4dbt,
    I have tried that prior, but it does not helped me at all - even when the number was significantly higher than string.
    Please dont forget to add good reputation if my advices were useful for you.
    How? Under this post there is "RATE THIS POST" button. Click on it.

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