This message contains graphics. If you do not see the graphics: Graphic Version.
Programmatically selecting a whole page

A lot of customers call our technical engineers to find out how to read a document row by row or how to select a complete page. In the past we have shown you how to read a document row by row.

This week, we are going to show you a very simple way to select a complete page of a document.

We will be using the CurrentInputPosition property, which returns or sets an array of three values (that specify the page, line and column number of the current text input position). We use this property to set the current input position to the first character position in the specified page. This position will be stored in the variable cStartPos using the SelStart property. In our example, the page number can be selected from a combo box. First of all, this combo box needs to be filled with the pages of the document.

Public Sub FillCombo(pages As Integer) Form1.Combo1.Clear For i = 1 To pages Form1.Combo1.AddItem i Next i End Sub

Now, we use CurrentInputPosition to set the caret to the first position of the next page. The variable cEndPos will be set with the SelStart property. First, however, we need to subtract one character position, so that the position specifies the last character position of the previous page. Once we have done that, we can select the complete page using SelStart and SelLength. SelLength specifies the length of the selection. We need to subtract cStartPos from cEndPos to get the length of the selection.

Private Sub SelectPage() Dim CurrentPositon() As Long CurrentPositon() = TXTextControl1.CurrentInputPosition cSelectedPage = Val(Combo1.Text) CurrentPositon(0) = cSelectedPage CurrentPositon(1) = 1 CurrentPositon(2) = 0 TXTextControl1.CurrentInputPosition = CurrentPositon() cStartPos = TXTextControl1.SelStart If cSelectedPage <> cCurPages Then CurrentPositon(0) = cSelectedPage + 1 CurrentPositon(1) = 1 CurrentPositon(2) = 0 TXTextControl1.CurrentInputPosition = CurrentPositon() cEndPos = TXTextControl1.SelStart - 1 Else TXTextControl1.SelStart = -1 cEndPos = TXTextControl1.SelStart End If TXTextControl1.SelStart = cStartPos TXTextControl1.SelLength = cEndPos - cStartPos TXTextControl1.SetFocus End Sub

The variable cCurPages needs to be updated if the user changes the contents of TX Text Control. We use the Change event to do this.

Private Sub TXTextControl1_Change() cCurPages = TXTextControl1.CurrentPages FillCombo (cCurPages) End Sub

As ever, we would be delighted to help you with this example. Please post your questions and requests for support into the TX Text Control Support Forum.

Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2019 Text Control GmbH. All Rights Reserved.