Multi line text areas

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
GBowlsby
Posts: 6
Joined: Saturday 24th April 2021 6:22pm

Multi line text areas

Post by GBowlsby »

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: Select all

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
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Multi line text areas

Post by stevedee »

GBowlsby wrote: Saturday 24th April 2021 6:27pm 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:-
  inputext = InputBox("Type something")
  TextArea1.Text = TextArea1.Text & Chr(10) & inputext ' Want this to be line 3...
...or:-
  TextArea1.Text &= Chr(10) & inputext ' Want this to be line 3...
[/gb]

I hope this helps.
GBowlsby
Posts: 6
Joined: Saturday 24th April 2021 6:22pm

Re: Multi line text areas

Post by GBowlsby »

Thank you. The &= works perfectly thank you. I really appreciate the help.
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Multi line text areas

Post by BruceSteers »

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

TextArea1.Insert(gb.Lf & inputext) ' Want this to be line 3...

If at first you don't succeed , try doing something differently.
BruceS
GBowlsby
Posts: 6
Joined: Saturday 24th April 2021 6:22pm

Re: Multi line text areas

Post by GBowlsby »

Good to know. Trying
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Multi line text areas

Post by stevedee »

BruceSteers wrote: Saturday 24th April 2021 9:48pm 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.
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Multi line text areas

Post by BruceSteers »

stevedee wrote: Sunday 25th April 2021 7:18am
BruceSteers wrote: Saturday 24th April 2021 9:48pm 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.
If at first you don't succeed , try doing something differently.
BruceS
Post Reply