

A desirable feature of a word processing application is to change the case of a word, sentence or entire document.
This sample application shows you, how to implement the different cases known from Microsoft Word in TX Text Control ActiveX.
We are going to implement the following case changes:
The implementation is really simple. We just loop through the selected text and replace the current character with its newly specified case, without loosing the format. If the current character is to be converted to an upper case character, it is replaced using this simplified code:
For i = mystart To (.SelStart + .SelLength - 1)
.SelStart = i
.SelLength = 1
selChar = .SelText
Select Case CaseHandler
Case 1:
changeText (LCase(.SelText))To change the current character, we use the following function:
Private Sub changeText(text As String)
With TXTextControl1
.SelStart = .SelStart + 1
.SelLength = 0
.SelText = text
.SelStart = .SelStart - 2
.SelLength = 1
.SelText = ""
End WithIn Visual Basic, the functions LCase and UCase offer the functionality to change the case of characters.
In the sample application, you will see how the other cases are implemented and which constraints need to be followed.
The minimum requirements for this sample application are TX Text Control ActiveX trial version and Visual Studio 6.