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