Solved

Text Box with scroll property

Posted on 2000-05-01
6
253 Views
Last Modified: 2010-05-02
Looking for a control that will display text and have an scroll bar property that will allow it to move at run time. Basically I need to view text as it is being written in a text box. On a standard text box, when it writes more than can be displayed I have to scroll to see the current line being written.  I need a way to either advance the scroll bar with code as lines are being written or find another way to write so that the most recent line is always  visible.
0
Comment
Question by:liberty6
  • 3
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
StingRaY earned 50 total points
ID: 2768136
Try This:

Private Sub Text1_Change()
    Text1.SelStart = Len(Text1.Text)
End Sub
0
 
LVL 1

Expert Comment

by:4P
ID: 2768163
I just tried it with VB 6, if you set the scrollbars property to vertical (and of course set the multiline to true) for your textbox then it does make the cursor position visible.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2768170
how is the textbox being written to?  stingray provides an answer except if the user tries to delete some characters that are, say, in the previous line, after hitting the backspace once it will advance the cursor to the end of the text.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 28

Expert Comment

by:AzraSound
ID: 2768173
thats why i ask about how it is being written to the textbox b/c the textbox automatically scrolls so i assume the questioner must be doing something out of the ordinary for it not to be scrolling.
0
 
LVL 15

Expert Comment

by:StingRaY
ID: 2768274
Well, If you want to identify current line your cursor is, try this code:

First Set Your Form.KeyPreview = True
and Put this code it to your form

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  If ActiveControl.Name = "Text1" Then
    If (KeyCode = vbKeyLeft) Or (KeyCode = vbKeyRight) Or (KeyCode = vbKeyUp) Or (KeyCode = vbKeyDown) Then
      Label1.Caption = CurLocation
    End If
  End If
End Sub

Private Sub Text1_Change()
  Label1.Caption = CurLocation
End Sub

Private Function CurLocation() As Long
  ' New Line Count
  Dim NewLineCount As Long
  Dim strTemp As String
  Dim pos As Long
 
  NewLineCount = 0
  pos = 1
  strTemp = Left(Text1.Text, Text1.SelStart)
  Debug.Print Text1.SelStart
  pos = InStr(pos, strTemp, vbLf)
  Do Until pos = 0
    NewLineCount = NewLineCount + 1
    pos = pos + 1
    pos = InStr(pos, strTemp, vbLf)
  Loop
  CurLocation = (NewLineCount + 1)
End Function

I think this will help you...
Label1 will display line number that your cursor is...
0
 
LVL 15

Expert Comment

by:StingRaY
ID: 2768276
liberty6:

Anyway , according to my code, I will see I didn't trap Page up and Page down and Arrow key from NumPad.
I just guide you to how-to.

Happy Programming.

StingRaY
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now