TXTextControl.TXTextControl.Load Method

Loads text in a certain format from a file and inserts it into the Text Control.

Syntax

TXTextControl.Load FileName[, Offset[, Format[, CurSelection]]]
Parameter Description
FileName

Specifies the file to load from.

Offset

Optional. Specifies the file position from where the data is read. When not specified or set to zero the data is read from the beginning.

Format

Optional. Specifies a format identifier. When not specified Text Control assumes Text Control's internal format (3). Otherwise it can be one of the following values:


Constant Description
1 - ANSI text Text in Windows ANSI format (an end of a paragraph is marked with the control characters 13 and 10).
2 - TX text Text in ANSI format (an end of a paragraph is marked only with the control character 10).
3 - TX Text including formatting attributes in the internal Text Control format. Text is stored in ANSI.
4 - HTML HTML format (Hypertext Markup Language).
5 - RTF RTF format (Rich Text Format).
6 - Unicode text Text in Windows Unicode format (an end of a paragraph is marked with the control characters 13 and 10).
7 - TX text Text in Unicode format (an end of a paragraph is marked only with the control character 10).
8 - TX Text including formatting attributes in the internal Text Control format. Text is stored in Unicode.
9 - Microsoft Word 97-2003 Microsoft Word 97-2003 format (*.doc).
10 - XML XML format (Extensible Markup Language).
11 - CSS CSS format (Cascading Style Sheet).
13 - Microsoft Word Microsoft Word format (*.docx).
CurSelection

Optional. When set to true the loaded data replaces the current selection or is inserted at the current input position. The new input position is behind the inserted data. When omitted or set to false the loaded data replaces the complete control contents independent of the current selection. The new input position is at the beginning of the data.

Return Value

The method returns the position in the file after the data has been loaded.

Data Types

FileName:    String
Offset:    Long
Format:    Integer
CurSelection:    Boolean
Return value:    Long

Example

This Basic example opens a file and loads its contents into TXTextControl1:

Private Sub mnuFile_Load_Click()
   On Error Resume Next
   ' Create an "Open File" dialog box
   CommonDialog1.Filter = "TX Demo (*.tx)|*.tx"
   CommonDialog1.DialogTitle = "Open"
   CommonDialog1.Flags = cdlOFNFileMustExist Or _
      cdlOFNHideReadOnly
   CommonDialog1.CancelError = True
   CommonDialog1.ShowOpen
   If Err Then Exit Sub
   ' Pass the filename to the text control
   TXTextControl1.Load CommonDialog1.filename
End Sub

See Also