Results 1 to 3 of 3

Thread: Text In TextBox Visible

  1. #1

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621

    Unhappy

    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


  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    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
    Mark
    -------------------

  3. #3
    Hyperactive Member gravyboy's Avatar
    Join Date
    Jan 2000
    Location
    Where I was before . . . if you don't know then you're new!
    Posts
    334

    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
    Matt G
    VS6 Ent SP5 @ Work
    VS6 Ent SP5 & VB.Net @ Home
    [email protected]



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width