Description
Replaces selected text in an edit control with a specified string.
Applies to
DataWindow, EditMask, InkEdit, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox, and DropDownPictureListBox controls
Syntax
editname.ReplaceText (string )
Argument |
Description |
---|---|
editname |
The name of the DataWindow, EditMask, InkEdit, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox, or DropDownPictureListBox control in which you want to replace the selected string. In a DataWindow control, the text is replaced in the edit control over the current row and column. |
string |
The string that replaces the selected text. |
Return value
Integer for DataWindow, InkEdit, and list boxes, Long for other controls.
For InkEdit, returns 1 for success and -1 if an error occurs. For other controls, returns the number of characters in string and -1 if an error occurs. If any argument's value is null, ReplaceText returns null.
Usage
If there is no selection, ReplaceText inserts the replacement text at the cursor position.
In a RichTextEdit control, the selection can include pictures.
Other ways to replace text
To use the contents of the clipboard as the replacement text, call the Paste function, instead of ReplaceText.
To replace text in a string, rather than a control, use the Replace function.
Examples
If the MultiLineEdit mle_Comment contains Offer Good for 3 Months and the selected text is 3 Months, this statement replaces 3 Months with 60 Days and returns 7. The resulting value of mle_Comment is Offer Good for 60 Days:
mle_Comment.ReplaceText("60 Days")
If there is no selected text, this statement inserts "Draft" at the cursor position in the SingleLineEdit sle_Comment3:
sle_Comment3.ReplaceText("Draft")
See also