Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scrolling textbox

Status
Not open for further replies.

f1car

Technical User
Apr 2, 2001
69
0
0
US
I want to make a scrolling textbox like in dos that has buffered capabilities.

The purpose of this box is for i/o communications and so if I decide to set the number of lines to ~1000, I want the first line to just scroll off, this way I still have the last 1000 lines to view, but I'm limiting my memory usage.

I can't seem to find the correct properities in textbox or richtextbox for this functionality.

Also can anyone susgest a free winsocket other than Dolphin?
 
Not sure what exactly you want, may be similar to this:

Private Sub cmdAddLines_Click()
Dim i As Integer

For i = 1 To 100
Text1.Text = Text1.Text & vbCrLf & "Line" & CStr(i)
Next i

Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Form_Load()
' Text1.MultiLine = True 'set in design mode
' Text1.ScrollBars = vbVertical 'set in design mode
End Sub
 
Let me rephrase the qualifications.

I have a textbox it contain 1000 lines for i/o communications.

Over the run lifetime of the text box probably 1,000,000's of lines of text will be sent to the textbox.

Currently if I set maxlines to 1000 then the textbox with either a)crash at line 1001 or b)never load line 1001, because lines 1 to 1000 are already loaded.

I need a scrolling textbox when line 1001 is received line #1 is discarded, line 1002 is received then line #2 is discarded. ect..... It scrolls just like a DOS command screen, but is a textbox that can be edited.
 
Here's some keywords to search on:


EM_LINESCROLL
EM_GETLINECOUNT
EM_LINEFROMCHAR
LockWindowUpdate



Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
Better then use a textbox with a list (checklist or simple).

list1 is the listbox
text1 is the textbox

Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
  If keyAscii = 13 then
    list1.addItem text1.Text
    text1.Text = ""
    If list1.ListCount > 1000 then list1.RemoveItem(0)
  End If
End Sub

When user hit enter:
1. the text1's Text is added to the list1
2. the text1's Text is being cleared
3. if the items in list1 are more than 1000 then the first is removed. As the items are added one by one, you could write : If list1.ListCount = 1001 then list1.RemoveItem(0)




-bclt
 
List box is easier, agree.

This is some dirty code for the text box:

Private Sub cmdAddLines_Click()
Dim strMyCurrentText() As String

strMyCurrentText = Split(Text1.Text, vbCrLf)
Text1.Text = Replace(Text1.Text, vbCrLf, "", 1, 1, vbBinaryCompare)

If UBound(strMyCurrentText) = 100 Then
Text1.Text = Trim$(Right$(Text1.Text, Len(Text1.Text) - Len(strMyCurrentText(0))))
End If

Text1.Text = Trim(Text1.Text) & vbCrLf & "My New Line"
Text1.SelStart = Len(Text1.Text)

End Sub

Private Sub Form_Activate()
Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Form_Load()
' Text1.MultiLine = True 'set in design mode
' Text1.ScrollBars = vbVertical 'set in design mode

Dim i As Integer

For i = 1 To 100
Text1.Text = Text1.Text & vbCrLf & " Line" & CStr(i)
Next i



End Sub
 
If UBound(strMyCurrentText) = 100 Then
Text1.Text = Trim$(Right$(Text1.Text, Len(Text1.Text) - Len(strMyCurrentText(0))))
End If"

This is the way that I'm currently manipulating my textbox.

I was hoping for a prebuilt-in (c++) function already in richtextbox or someother OCX plug-in???

Also what about the free WinSocket?
 
You guys are the best, thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top