Text, TextLength Property

Purpose

Text returns or sets the text contained in an object. TextLength returns the number of characters in a RichEdit control.

Syntax

Object.Text [ = a$ ]

% = RichEdit.TextLength

Object:Ocx Object
x!: Single
a$: sexp

Description

RichEdit and TextBox control the value specifies the text appearing in the control.

ComboBox control (Style property set to 0 [Dropdown Combo] or to 1 [Simple Combo]) - returns or sets the text contained in the edit area. ComboBox control (Style property set to 2 [Dropdown List]) and ListBox control - returns the selected item in the list box; the value returned is always equivalent to the value returned by the expression List(ListIndex).

The TextLength is a RichEdit property returning the current number (Long) of characters in the control.

Example

OpenW 1 : AutoRedraw = 1

Ocx RichEdit red = "", 10, 10, 300, 400 : .MultiLine = True : .BorderStyle = 1

red.SelColor = 255 : red.SelText = "Hello " : red.SelColor = 0 : red.SelText = "World"

Text 320, 10, "Text Length: " & red.TextLength

Text 320, 30, "Plain Text:"

Ocx Label lbl = "", 320, 45, 300, 300 : .MultiLine = True : lbl.Text = red.Text

Do : Sleep : Until Me Is Nothing

 

Sub red_Change

Text 320, 10, "Text Length: " & red.TextLength & Space(5)

If Not lbl Is Nothing Then lbl.Text = red.Text

EndSub

See Also

ComboBox, ListBox, TextBox, RichEdit, Command, Option, CheckBox, Frame, Label, MenuItem, Node, Panel, ListItem, ColumnHeader, Tab

{Created by Sjouke Hamstra; Last updated: 21/07/2022 by James Gaite; Other Contributors: Jean-Marie Melanson}