Results 1 to 9 of 9

Thread: Textbox Problem

  1. #1

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Textbox Problem

    I have a string(as StringBuilder) of 35,660 characters that I put into a textbox. The problem is that it is slow. AT first I thought my problem was the .tostring of the stringbuilder but that was not the case. In the end I created a rich textbox and executed the following in the debugger

    tstRTB.Text = lstANSa(pANS.Value).ToString 'rich textbox
    txtFOC.Text = lstANSa(pANS.Value).ToString 'textbox


    The rich textbox example executes as soon as you press F8. The textbox version takes seconds.

    What am I missing. BTW - I reversed the order of the statements but the results were the same.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Textbox Problem

    What is pANS? What is lstANSa? Remember that we know nothing about your project other than what you tell us. With such cryptic variable names you can't assume that what you're doing is obvious.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Textbox Problem

    lstansa is an array of stringbuilders. pans.value is a numeric up down.

    dim s as string
    s=lstANSa(pANS.Value).ToString

    the above two lines execute as soon as you press F8.
    if i then try to assign s to the textbox it takes seconds also.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Textbox Problem

    Are you doing anything funky on the TextChanged event?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Textbox Problem

    What's the textbox.MaxLength property is set to?

  6. #6

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Textbox Problem

    There is not a changed event in my code. maxlength, as i discovered, only applies to the ui. but it was set to 0.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Textbox Problem

    something else i noticed about textbox. if i used the arrow keys they were becoming part of the text, at least right arrow was for sure. doesn't seem to happen in rich textbox.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8
    Member
    Join Date
    Feb 2008
    Posts
    44

    Re: Textbox Problem

    I used this code to test your original question. I noticed that if you set the textbox multiline property to false the textbox fills with the text as fast as the richtextbox. I also observed the the lag when the textbox was set to multiline. Not much you can do about that I guess but is there a reason why you wouldn't just use the richtextbox?

    Code:
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim s As New String("A"c, 36000)
            Me.RichTextBox1.Text = s
            Me.TextBox1.Text = s
    
        End Sub

  9. #9

    Thread Starter
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Textbox Problem

    jw, thanks for the confirmation. i thought i was going crazy, though i already may be there. in the rich box multiline was true also, but does not seem to be affected.

    i have switched to rich textbox and the problem went away. of course i have already found an aspect of rich textbox i don't like. when i paste into it it brings formatting with it.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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