Clear

Description

Deletes selected text or an OLE object from the specified control, but does not store it in the clipboard.

Applies to

DataWindow, EditMask, InkEdit, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox, DropDownPictureListBox, OLE controls, and OLEStorage objects

Syntax

objectname.Clear ( )

Argument

Description

objectname

One of the following:

  • The name of the DataWindow control, EditMask, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox or DropDownPictureListBox from which you want to delete (clear) selected text.

  • The name of an OLE control or storage object variable (type OLEStorage) from which you want to release its OLE object.

If objectname is a DropDownListBox or DropDownPictureListBox, its AllowEdit property must be true.

Returns

Integer for DataWindow, InkEdit, and list boxes, Long for other controls.

For edit controls, returns the number of characters that Clear removed from objectname. If no text is selected, no characters are removed and Clear returns 0. If an error occurs, Clear returns -1.

For OLE controls and storage variables, returns 0 if it succeeds and -9 if an error occurs.

If objectname is null, Clear returns null.

Usage

To select text for deleting, the user can use the mouse or keyboard. You can also call the SelectText function in a script.

To delete selected text and store it in the clipboard, use the Cut function.

Clearing the OLE object from an OLE control deletes all references to it. Any changes to the object are not saved in its storage object or file.

Clearing an OLEStorage object variable breaks any connections established by Open or SaveAs between it and a storage file (when Open or SaveAs is called for the OLEStorage object variable). It also breaks connections between it and any OLE controls that have called Open or SaveAs to connect to the object in the storage variable.

Examples

Example 1

If the text in sle_comment1 is Draft and it is selected, this statement clears Draft from sle_comment1 and returns 5:

sle_comment1.Clear()

Example 2

If the text in sle_comment1 is Draft, the first statement selects the D and the second clears D from sle_comment1 and returns 1:

sle_comment1.SelectText(1,1)

sle_comment1.Clear()

Example 3

This example clears the object associated with the OLE control ole_1, leaving the control empty:

integer result

result = ole_1.Clear()

Example 4

This example clears the object in the OLEStorage object variable olest_stuff. It also leaves any OLE controls that have opened the object in olest_stuff empty:

integer result

result = olest_stuff.Clear()

See also