• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

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
0
tzachari
Asked:
tzachari
1 Solution
 
tzachariAuthor Commented:
Edited text of question.
0
 
jbilCommented:
You could add this to code

Text1.SelStart = Len(Text1)
0
 
rmichelsCommented:
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
vbWayneCommented:
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


0
 
TYoungCommented:
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
0
 
mikeTmikeCommented:
this code here works in vb6 but you must set the value of myMax to the number of lines

'----------------start
Const myMax As Integer = 5
Dim myNOE As Integer


Private Sub Timer1_Timer()
    Text1.Text = Text1.Text & Format(Now, "General Date") & vbCrLf
    GenreArray = Split(Text1.Text, Chr(13))
    myNOE = myNOE + 1
    If myNOE > myMax Then
        Text1.Text = ""
        For a = 1 To myMax
            Text1.Text = Text1.Text & Right(GenreArray(a), Len(GenreArray(a)) - 1) & vbCrLf
        Next a
    End If
End Sub
'----------------end

try it.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now