|
-
Aug 1st, 2000, 03:05 AM
#1
Thread Starter
Fanatic Member
Hi Everybody!
Does anyone know how to add text to a text box and when it reaches the bottom of the text box it automatically scrolls to the active line.
I have an application that imports numerous text files.
It adds a line in a text box to show what it has imported from each text file.
Your mission if you chose to accept:
If there are a lot to import and the text reaches the bottom of the text box it disappears. I want the text box to scroll down so the current line is allways in view.
Thanks in advance.
Gary Lowe 
VB6 (Enterprise) SP5
ADO 2.6
SQL Server 7 SP3
OK I know my spelling and grammer is crap so don't quote me on it!
To err is human to take the P! is only natural !!
Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip

-
Aug 1st, 2000, 03:26 AM
#2
Frenzied Member
You could base your code on this sort of thing...
Code:
Private Sub Command1_Click()
Text1 = Text1 & Now() & vbCrLf
Text1.SelStart = GetLastVBCRLF(Text1)
End Sub
Private Function GetLastVBCRLF(strIN As String) As Long
Dim i As Long
Dim char As String
For i = Len(strIN) To 1 Step -1
char = Mid(strIN, i, 2)
If char = vbCrLf Then
Exit For
End If
Next i
GetLastVBCRLF = i
End Function
-
Aug 1st, 2000, 05:25 AM
#3
Hyperactive Member
My Answer
Gazza,
Try this:
Code:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Public Const EM_GETLINECOUNT = &HBA
Public Const EM_LINESCROLL = &HB6
Private Sub Text1_Change()
Dim lCount&, lRes&
lCount = SendMessage(ByVal Text1.hwnd, ByVal EM_GETLINECOUNT, 0, 0)
If lCount >= 10 Then ' or any value you like
lRes = SendMessage(ByVal Text1.hwnd, ByVal EM_LINESCROLL, 0, 1)
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|