Solved

Text Box with scroll property

Posted on 2000-05-01
6
263 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 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

728 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