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 » 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?

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: 456
Joined: Monday 20th March 2017 6:06pm

Re: Multi line text areas

Post by stevedee » Saturday 24th April 2021 7:07pm

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 » Saturday 24th April 2021 8:09pm

Thank you. The &= works perfectly thank you. I really appreciate the help.

User avatar
BruceSteers
Posts: 654
Joined: Thursday 23rd July 2020 5:20pm

Re: Multi line text areas

Post by BruceSteers » 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

using Insert() does a cleaner appending

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

Wishing well
Bruce

If at first you don't succeed , try it differently.

GBowlsby
Posts: 6
Joined: Saturday 24th April 2021 6:22pm

Re: Multi line text areas

Post by GBowlsby » Saturday 24th April 2021 11:02pm

Good to know. Trying

User avatar
stevedee
Posts: 456
Joined: Monday 20th March 2017 6:06pm

Re: Multi line text areas

Post by stevedee » 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.

User avatar
BruceSteers
Posts: 654
Joined: Thursday 23rd July 2020 5:20pm

Re: Multi line text areas

Post by BruceSteers » Sunday 25th April 2021 12:20pm

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.
Wishing well
Bruce

If at first you don't succeed , try it differently.

Post Reply