MultiLine returns or sets a value indicating whether a TextBox or RichEdit control can accept and display multiple lines of text. MaxLength sets maximum number of character the control accepts.
object.MultiLine [= boolean]
object.MaxLength [= value]
object:TextBox, RichEdit
The default is 0, so that the edit control ignores carriage returns and restricts data to a single line.
A multiple-line TextBox control wraps text as the user types text extending beyond the text box. You can also add scroll bars to larger TextBox controls using the ScrollBars property. If no horizontal scroll bar is specified, the text in a multiple-line TextBox automatically wraps.
Maxlength specifies a long integer with the maximum number of characters a user can enter in the control. The default for the MaxLength property is 0, indicating no maximum other than that created by memory constraints on the user's system. Any number greater than 0 indicates the maximum number of characters.
Ocx Label lbl = "Length of Text:", 10, 10, TextWidth("Length of Text:"), 14 : lbl.BackColor = $FFFFFF
Ocx TextBox tb1 = "", 15 + TextWidth("Length of Text:"), 10, 30, 14 : tb1.BorderStyle = 1 : tb1.MaxLength = 3
Ocx CheckBox chk = "Allow Multiline Text?", 10, 30, 115, 14 : chk.BackColor = $FFFFFF
Ocx TextBox tb2 = "", 10, 50, 200, 60 : tb2.BorderStyle = 1
Do : Sleep : Until Me Is Nothing
Sub chk_Click
// Changing the state of Multiline clears the text from the textbox
Local t$ = tb2.Text (* Store the value in tb2 *)
tb2.MultiLine = - chk.Value
// It can, on occasion, change the Borderstyle setting too
// Resetting using tb2.BorderStyle = 1 actually gives Borderstyle 2
// although the BorderStyle property still returns a value of 1
// This is known bug
Trace tb2.BorderStyle
tb2.BorderStyle = 1
tb2.Text = t$
EndSub
Sub tb1_LostFocus
If Not tb1 Is Nothing
tb2.MaxLength = Val(tb1.Text)
EndIf
EndSub
On a form with a default button, pressing ENTER in a multiple-line TextBox control moves the focus to the next button and executes the button. To prevent this behaviour set WantSpecial = True or use the Ctrl-Enter key combination when entering the data.
{Created by Sjouke Hamstra; Last updated: 20/10/2014 by James Gaite}