Link to home
Start Free TrialLog in
Avatar of tzachari
tzachari

asked on

Multiline textbox help

Hi All,
I have a textbox with the multiline property set to true. I am using the text box to display the general time every two seconds.
  My problem is that when I have the text box completely filled with time status info, I can't seem to see the time info after that point. I tried adding a vertical scroll bar, but that just moved the scroll bar up during runtime and the latest time was not available to the user.
  Ideally, once the text box is filled with info(up to the last line), I would like to have the first line of the textbox disappear,move rest of the data up by a line, so that there is one line of space at the bottom for the next time info. This way, I can always see the latest time status(real time) at the last line of the textbox.

I hope I was clear in explaining my problem.

Following is the code. I have a textbox placed on a form, its multiline property set to true, I have a timer in the form with an interval of 2 seconds, and I am trying to display the general time every 2 seconds.

Private Sub Timer1_Timer()
Text1 = Text1 & Format(Now, "General Date") & vbCrLf
End Sub

Thanks for the help
Zack
Avatar of tzachari
tzachari

ASKER

Edited text of question.
You could add this to code

Text1.SelStart = Len(Text1)
Also, you might try a list box, it may be faster.

After adding you latest time, set selected(index) to true where index is the number of item you just added. (index) is zero based.

For i = 1 To 1000
    List1.AddItem i
    List1.Selected(i - 1) = True
    List1.Refresh
Next
Why wait to fill the text box...
add a counter and increment it every time you add a line when it reaches 100 or whatever clear the text up to the last line and start over.

Private Sub Timer1_Timer()

dim intCounter as integer

Text1 = Text1 & Format(Now, "General Date") & vbCrLf

intCounter = intCounter + 1
if intcounter = 100 then
text1.SelStart = 0
text1.SelLength = Len(text1.text)
text1.text = Format(Now, "General Date") & vbCrLf
End If

End Sub


vbWayne... no need for all of this:

text1.SelStart = 0
text1.SelLength = Len(text1.text)
text1.text = Format(Now, "General Date") & vbCrLf


Just use:

Text1 = Format(Now, "General Date") & vbCrLf
ASKER CERTIFIED SOLUTION
Avatar of mikeTmike
mikeTmike

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial