Code snippet:
Box1=Controls.AddMultiLineTextBox(10,10)
Controls.SetSize(Box1,600,400)
Controls.SetTextBoxText(Box1,"How's this? Also, you can just type in what you want in the box.")
JR
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
How do you insert lines into the MuliLineTextBox control ?
Thanks
Code snippet:
Box1=Controls.AddMultiLineTextBox(10,10)
Controls.SetSize(Box1,600,400)
Controls.SetTextBoxText(Box1,"How's this? Also, you can just type in what you want in the box.")
JR
in the case of multiline how do I go to the next line ?
BS
Code snippet:
tb=Controls.AddMultiLineTextBox(20,0)
Controls.SetSize(tb,500,400)
Return=text.GetCharacter(10)
Controls.SetTextBoxText(tb,"This and that"+return+return)
LDFocus.SetFocus(tb)
LDControls.SetCursorPosition(tb,100)
If you are manually entering data in the multiline textbox just hit the return key. It will take you to the next line. If you are entering it through your program then you need to add the return as I did in the above snippet. This is more complex as you need to have the LitDev extension loaded.
Here's a way to get to the next line without using an extension.
tb=Controls.addmultilinetextbox(10,0)
Controls.SetTextBoxText(tb,"This and That")
Text=Controls.GetTextBoxText(tb)
return=text.GetCharacter(10)
Controls.SetTextBoxText(tb,text.Append(text,return+"Now This"))
JR
GraphicsWindow.Title = "Single / Multi Line Text Box Demo"
GraphicsWindow.BackgroundColor = "darkgray"
GraphicsWindow.FontSize = 20
GraphicsWindow.BrushColor = "Black"
txtBox = Controls.AddMultiLineTextBox(10, 10) ' MultiLine text box'
'txtBox = Controls.AddTextBox(10, 10) ' 'SingleLine text box'
Controls.SetSize(txtBox,333,77)
txtboxshape = Shapes.AddText("-------")
Controls.Move(txtboxshape, 200,100)
txtcharshape = Shapes.AddText("-")
Controls.Move(txtcharshape, 150,200)
txtkeyshape = Shapes.AddText("---")
Controls.Move(txtkeyshape, 100,250)
txtboxreturn = Shapes.AddText("")
Controls.Move(txtboxreturn , 200,150)
hexBox = Controls.AddMultiLineTextBox(10, 300)
Controls.SetSize(hexBox,590,130)
Controls.TextTyped = OnTextTyped ' subroutine to handle textbox events'
GraphicsWindow.TextInput = OnTextInput
GraphicsWindow.KeyUp = InKey
Sub OnTextTyped ' msb requires one routine to handle all textboxes'
If (Controls.LastTypedTextBox = txtBox) then ' action for text box '
buf = Controls.GetTextBoxText(txtBox)
Shapes.SetText(txtboxshape , buf)
GraphicsWindow.DrawText(10, 100, "Text boxed typed:")
buf2 = ""
For i = 1 to Text.GetLength(buf)
buf2 = Text.Append(buf2, Text.GetCharacterCode(Text.GetSubText(buf, i,1)) +" " )
EndFor
Controls.SetTextBoxText(hexBox , buf2)
EndIf
EndSub
Sub OnTextInput ' Only at Start without Focus to TextBox'
GraphicsWindow.DrawText(10, 200, "Character: ")
Shapes.SetText(txtcharshape, GraphicsWindow.LastText)
EndSub
Sub InKey
key = GraphicsWindow.LastKey
GraphicsWindow.DrawText(10, 250, "Key: ")
Shapes.SetText(txtkeyshape, key)
if key = "Return" Then
GraphicsWindow.DrawText(10, 150, "Text boxed return: ")
Shapes.SetText(txtboxreturn, Controls.GetTextBoxText(txtbox))
EndIf
EndSub
If you use small Visual Basic, you can drag a textBox from the toolbox and drop it on the form, and use this line of code in the code editor:
TextBox1.MultiLine = True
you can use the move to previous and next lines by such code:
TextBox1.MuliLine = True
'------------------------------------------------
Sub BtnNextLine_OnClick()
pos = TextBox1.CaretIndex
txt = TextBox1.Text
For i = pos To txt.Length
If txt[i] = Chars.Cr Then
If txt[i + 1] = Chars.Lf Then
TextBox1.CaretIndex = i + 1
Else
TextBox1.CaretIndex = i
EndIf
ExitLoop
EndIf
Next
TextBox1.Focus()
EndSub
'------------------------------------------------
Sub BtnPrevLine_OnClick()
pos = TextBox1.CaretIndex
txt = TextBox1.Text
For i = pos To 1 Step -1
If txt[i] = Chars.Lf Then
If txt[i - 1] = Chars.Cr Then
TextBox1.CaretIndex = i - 1
Else
TextBox1.CaretIndex = i
EndIf
ExitLoop
EndIf
Next
TextBox1.Focus()
EndSub
You can try this code in the TextBox Lines
sample in the samples folders.