Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1529

How to track TextBox carot position, notify use if text1.SelStart = Len(text1.Text)

$
0
0
On the Form two ListBoxes are displayed side by side and a TextBox is on the right side.
ListBox 2 is displayed having several CheckBoxes. When the user clicks on a CheckBox,
from Private Sub List2_Click() I use selItem = List2.ListIndex to select an Article in a .txt file. Many times the length of the Article is too great to be assigned to text1.Text so I divide it into portions using .Text = Mid(Art, (thisPortion * ArtMaxSize ) + 1, ArtMaxSize), where thisPortion starts out as 0 and ArtMaxSize = the maximum length of text1.Text.
The TextBox is Locked (Read-Only).
I tried to track the TextBox carot position with a Do Loop before List2_Click() End Sub:
Do
Select Case text1.SelStart
Case 0 'at beginning of thisPortion
'InputBox(Read previous portion of Article Y/N)
Case Len(text1.Text)
' InputBox(Read next portion of Article Y/N)
'if yes then go to next portion, thisPortion=thisPortion +1
Case Else
'Let user move around in TextBox
End Select
Loop

The Do Loop causes the Form with the two ListBoxes and the TextBox not to be displayed. Do I need to Set the Focus on the TextBox before going into the Do Loop or is there a better way to track the TextBox carot position? I also tried using a Private Sub text1_KeyDown(KeyCode as Integer, Shift As Integer) to trap the navigation keys and setting the carot location for vbKeyLeft, VbKeyRight, etc. but this seemed more difficult to code.
Maybe someone knows of a Windows API for vb6 where I can track the TextBox carot position while moving around in the TextBox and notify the user when reaching the end of this portion, e.g. "Please Wait, Loading Portion 3 of 5."
Please help.
Thanks,
John

Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>