Solved

Text Box with scroll property

Posted on 2000-05-01
6
258 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 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