From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

TextEdit.AddText(text as String)

New in 2019r2

Supported for all project types and targets.

Adds the passed text to the current Text. Call AddText rather than using the + operator to add text to existing text.


This example reads a text field in blocks of 1000 characters using Read.

Var f As FolderItem
Var dlg As OpenDialog
Var t As TextInputStream

// create a new openDialog
dlg = New OpenFileDialog
// set what type of file it looks for
dlg.Filter = "text/plain"

// run the dialog
f = dlg.ShowModal

// check to make sure the user didn't click cancel
If f <> Nil Then
t = TextInputStream.Open(f)
// Read all of the text, 1000 characters at a time
// into the TextField
While Not t.EndOfFile
myTextArea.AddText(t.Read(1000, Encodings.UTF8))
Catch error As IOException
// the file could not be a read as a text file
MessageBox("The selected file is not a text file. Error: " + error.Message)
End If
// the user clicked cancel... just ignore it
End If