Multi line text areas

Post

Posted
Rating:
#1 (In Topic #642)
Trainee
I am new to GAMBAS. I have VB.net experience. What I am trying to do is append text to my textarea. In VB.net I would use textbox.appendtext("Line" & vbcrlf)

Below is where I am at and the issue is with the inputext replaces the information in the box and not appends the text. So what am I doing wrong?

Code

Dim inputext As String = ""
  
  TextBox1.Text = "Hello World " 'Works as expected
  TextArea1.Text = "Line 1" & Chr(10) & "Line 2" 'Works as expected
  
  'Message("Click ok")
  
  inputext = InputBox("Type something")
  TextArea1.Text = Chr(10) & inputext ' Want this to be line 3 but it replaces text
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’

GBowlsby said

I am new to GAMBAS. I have VB.net experience. What I am trying to do is append text to my textarea. In VB.net I would use textbox.appendtext("Line" & vbcrlf)

…Below is where I am at and the issue is with the inputext replaces the information in the box and not appends the text. So what am I doing wrong?…

Welcome to GambasOne
You just need to add the new text at the end:-

Code (gambas)

  1.   inputext = InputBox("Type something")
  2.   TextArea1.Text = TextArea1.Text & Chr(10) & inputext ' Want this to be line 3...

…or:-

Code (gambas)

  1.   TextArea1.Text &= Chr(10) & inputext ' Want this to be line 3...

I hope this helps.
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
 Thank you. The &= works perfectly thank you. I really appreciate the help.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
if there is a lot of text textarea can be glitchy using "Text = Text &" or "&=" as it refreshes the whole text

using Insert() does a cleaner appending

Code (gambas)

  1.  
  2. TextArea1.Insert(gb.Lf & inputext) ' Want this to be line 3...
  3.  
  4.  
Online now: No Back to the top

Post

Posted
Rating:
#5
Trainee
Good to know. Trying
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

if there is a lot of text textarea can be glitchy using "Text = Text &" or "&=" as it refreshes the whole text…


That's interesting Bruce, what does this glitch look like?

I have never seen a problem.
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said

if there is a lot of text textarea can be glitchy using "Text = Text &" or "&=" as it refreshes the whole text…


That's interesting Bruce, what does this glitch look like?

I have never seen a problem.

it does odd things to the scroll bar as the objects text gets a complete re-write. the glitches are not so noticable on speedy machines.
I moaned about the odd behaviour on the m/l and Benoit gave me the advice on using Insert()

I made a quick clip..
In the clip the textarea on the top has Text &= "Hello"  , the lower one uses Insert()
you can see the scrollbar oddness in the top textarea as i click to add text. (just about)
Like i say more noticable on slower machines and if textarea has lots and lots of text to rewrite.
<VIDEO content="http://138.68.116.47/screenrecord-2021-04-25_13.16.08.webm">[video]
[/video]</VIDEO>
Online now: No Back to the top
1 guest and 0 members have just viewed this.