Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8582557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:19:17+00:00 2026-06-11T21:19:17+00:00

We have a VB6 program that does some string processing in a loop (approximately

  • 0

We have a VB6 program that does some string processing in a loop (approximately 500 times) and appends info to a textbox. Each iteration on the loop includes basic operations like Trim, Len, Left, Mid, etc, and finally appends the string to a textbox (the whole form is still invisible at this point). Finally, after the loop, the code calls Show on the form.

On Windows XP, these 500 loops take about 4 seconds. On Windows 7, the exact same code runs in about 90 seconds.

Any suggestions on how to fix this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:19:18+00:00Added an answer on June 11, 2026 at 9:19 pm

    I’m guessing you append the text box on each loop iteration… If you can, store everything in a variable and append it to the TextBox once after the loop is finished. Displaying text in a text box takes a lot of time in VB6.

    EDIT:
    After further investigation and testing, I came to a conclusion that performance on directly assigning strings to the Text property of a TextBox degrades dramatically when the length of the control reaches maximum. The maximum on my PC is 65535 for some reason, even though according to MSDN its

    Windows NT 4.0, Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: For single line text box controls, if the MaxLength property is set to 0, the maximum number of characters the user can enter is 2147483646 or an amount based on available memory, whichever is smaller

    Basically what seems to be happening, if you keep adding text to the TextBox each iteration, it isn’t that slow until you reach maximum. What’s even more puzzling, when you try to add text beyond the maximum, there will be no errors, but performance degrades significantly.

    In my test loop I go from 0 to 12773 I have this:

    Text2.Text = Text2.Text + CStr(a) + " "

    So when the loop is completed in 4 seconds, the Text2.Text is 65534 characters long. Now, when I double the loop to go beyond the maximum allowed length of the TextBox, it takes three times as much time to complete it.

    12773 – 4 seconds

    12773*2 – 16 seconds

    After realizing this, my first thought was to replace the TextBox with a RichTextBox. But the performance of the latter is even worse. This is assuming you update it every iteration.

    It seems that you are stuck with a dilemma – suffer slow performance or change the code to update text box only once after the loop is completed. Further, due to TextBox‘s maximum length limit, I recommend switching to a RichTextBox or depending on the purpose of this – some other object.

    I hope my findings are helpful – it has certainly been fun finding out all these little programming quirks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a COM Callable Wrapper that I'm using from a VB6 program, but
I Have a program written in VB6 that reads a long text file and
I have a VB6 application that is creating a JSON string and posting it
I have a VB6 program that is failing on a particular machine. The nature
I have a program built with VB6 and using some 32-bit DLL's . Will
We have a program written in VB6 that in the past connected to Oracle
I have a VB6 program that someone recently helped me convert to VB.NET In
I have a VB6 program that uses a n Access backend. The query that
I have a relatively simple select statement in a VB6 program that I have
I have a VB6 program that adds a column to an MS Access database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.