?
Solved

Text Box with scroll property

Posted on 2000-05-01
6
Medium Priority
?
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
StingRaY earned 200 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

765 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