473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

textbox update

Hello all:
What is wrong with my code? I want it to update the new text on the
textbox on every iteration of my loop. But instead the textbox updates
all info at the end of the loop. I also have to scroll down to see the
last entries. Once I get it to work the way I want is there a property
that will always keep that last entry visible? I mean, scroll down as
new data is displayed.

Here is mi code

For i = 0 to 1000
dataToTextBox = dataToTextBox & myDataString(i) & vbCrLf
txtData.Text = dataToTextBox
bufferToText = bufferToText & bufferVar(i)
txtBuffer.Text = bufferToText
Next i

Thanks in advance
Jul 17 '05 #1
3 12762
With the code you're using you've got to give Windows a chance to update the
controls. Normally, e.g. with a listbox or label, you would place a
<controname>.Refresh statement in the appropriate place. But text boxes are
a bit different.

In your code you are adding a new line and linefeed to dataToTextBox, then
blasting all that data back into txtData. Ditto for txtBuffer. If you add
the Refresh statements your text will update, but flicker like hell.

What you need to do is append your new data to the end of the textboxes
rather than replace the entire contents, then save the current contents to
the string variable if still required. This is the idea ...

for cnt = 1 to 1000

'moves to end of text, scrolling if needed
text1.selstart=len(text1.text)

'append the new data
text1.seltext = myDataString(cnt) & vbCrLf

'save new text contents to string if still needed
dataToTextBox = text1.text

'repeat for other textbox

next

That will do the trick and not require the Refresh statement.

--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
"Sonoman" <bi*******@microsoft.com> wrote in message
news:i6********************@comcast.com...
: Hello all:
: What is wrong with my code? I want it to update the new text on the
: textbox on every iteration of my loop. But instead the textbox updates
: all info at the end of the loop. I also have to scroll down to see the
: last entries. Once I get it to work the way I want is there a property
: that will always keep that last entry visible? I mean, scroll down as
: new data is displayed.
:
: Here is mi code
:
: For i = 0 to 1000
: dataToTextBox = dataToTextBox & myDataString(i) & vbCrLf
: txtData.Text = dataToTextBox
: bufferToText = bufferToText & bufferVar(i)
: txtBuffer.Text = bufferToText
: Next i
:
: Thanks in advance

Jul 17 '05 #2
Thank you Randy, the .Refresh worked beautifully because I have an
introduced delay on my loop. It does flicker but it is barely
noticeable. The screen updates about every 1/2 second so It looks fine.
Later on today with more time I will change all the code to the better
method.

Once again, thanks!

Randy Birch wrote:
With the code you're using you've got to give Windows a chance to update the
controls. Normally, e.g. with a listbox or label, you would place a
<controname>.Refresh statement in the appropriate place. But text boxes are
a bit different.

In your code you are adding a new line and linefeed to dataToTextBox, then
blasting all that data back into txtData. Ditto for txtBuffer. If you add
the Refresh statements your text will update, but flicker like hell.

What you need to do is append your new data to the end of the textboxes
rather than replace the entire contents, then save the current contents to
the string variable if still required. This is the idea ...

for cnt = 1 to 1000

'moves to end of text, scrolling if needed
text1.selstart=len(text1.text)

'append the new data
text1.seltext = myDataString(cnt) & vbCrLf

'save new text contents to string if still needed
dataToTextBox = text1.text

'repeat for other textbox

next

That will do the trick and not require the Refresh statement.

Jul 17 '05 #3
Unless there is a reason not to use the SelStart method, I strongly urge you
at least give that a try.

--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
"Sonoman" <bi*******@microsoft.com> wrote in message
news:5o********************@comcast.com...
: Thank you Randy, the .Refresh worked beautifully because I have an
: introduced delay on my loop. It does flicker but it is barely
: noticeable. The screen updates about every 1/2 second so It looks fine.
: Later on today with more time I will change all the code to the better
: method.
:
: Once again, thanks!
:
: Randy Birch wrote:
: > With the code you're using you've got to give Windows a chance to update
the
: > controls. Normally, e.g. with a listbox or label, you would place a
: > <controname>.Refresh statement in the appropriate place. But text boxes
are
: > a bit different.
: >
: > In your code you are adding a new line and linefeed to dataToTextBox,
then
: > blasting all that data back into txtData. Ditto for txtBuffer. If you
add
: > the Refresh statements your text will update, but flicker like hell.
: >
: > What you need to do is append your new data to the end of the textboxes
: > rather than replace the entire contents, then save the current contents
to
: > the string variable if still required. This is the idea ...
: >
: > for cnt = 1 to 1000
: >
: > 'moves to end of text, scrolling if needed
: > text1.selstart=len(text1.text)
: >
: > 'append the new data
: > text1.seltext = myDataString(cnt) & vbCrLf
: >
: > 'save new text contents to string if still needed
: > dataToTextBox = text1.text
: >
: > 'repeat for other textbox
: >
: > next
: >
: > That will do the trick and not require the Refresh statement.
: >

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nic | last post by:
Hey, I have an ASP-application. In the ASPX I have an <asp:dropdownlist ..>. Now when I leave this control I want to initialisize some other fields. In window forms we uses the onleave event but...
28
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I...
2
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different...
6
by: Alex | last post by:
I am a newbie to ASP.NET... What I was trying to do... but yet to succeed in... I am building a customer info database... and on default, I want to display the customer's basic information in...
4
by: John Rose | last post by:
I have one databound TextBox on a page with one button. The TextBox loads the correct SQL record data but typing a new string into the Textbox fails to change the DataSet. Any ideas? There must...
7
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
6
by: Frank | last post by:
Hopefully this is the correct group for this message. My previous post to (I assume) a non-.net group was not welcomed. I have a form with 7 text boxes that are all bound to fields of a...
16
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub...
6
by: JohnR | last post by:
I have a table with 1 row which is used to hold some application wide items (one item per field, hence I only need 1 row). I want to bind one of the fields to a textbox. After setting up the...
0
KalariaNitya
by: KalariaNitya | last post by:
Hello, could anybody help me? i have gridview, inside gridview i have one Update button & textbox update button update the quantity entered in textbox. i want to update the quantity on textbox on...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.