ReplaceText

Description

Replaces selected text in the edit control for the current row and column with a specified string.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control

Web ActiveX

DataWindow control

Syntax

PowerBuilder

long editname.ReplaceText ( string string ) 

Web ActiveX

number editname.ReplaceText ( string string ) 

Argument

Description

editname

A reference to a DataWindow control

string

The string that replaces the selected text

Returns

Returns the number of characters in string and –1 if an error occurs.

If any argument’s value is null, in PowerBuilder and JavaScript the method returns null.

Usage

If there is no selection, ReplaceText inserts the replacement text at the cursor position.

To use the contents of the clipboard as the replacement text, call the Paste method instead of ReplaceText.

NotePowerBuilder environment For use with other PowerBuilder controls, see ReplaceText in the PowerScript Reference.

Examples

Example 1

If the DataWindow edit control 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 text in the edit control is “Offer Good for 60 Days”:

dw_salesoffer.ReplaceText("60 Days")

Example 2

If there is no selected text, this statement inserts “New product” at the cursor position in the edit control for dw_products:

dw_products.ReplaceText("New product")

See also