Textfield and number

I have the follow code:

Var r As Integer
For r = 0 to 1000
Texfield1.text = r.ToText
Next

Because it prints only the final number and not the numbers in succession ?

Thanks
BS

Hi @Sardo_Giovanni

Where is that code placed? Looks like it is executed before the TextField has given time to refresh its contents… so, yes, what you see is the last number assigned to it :wink:

how do I display all the numbers ?

Use TextArea set to Multiline (default I believe)

Var r As Integer For r = 0 to 1000 Textarea1.text = textarea1.text + " " + endofline + r.ToText Next

Do you want to show something like this?
ezgif.com-video-to-gif (2)

Check Examples - Platforms - Desktop - Updating UI From Thread examples
(the above screen is a modification of ‘Using a Timer’ example)

1 Like

Yes

inside of a method the event loop did not continue so you see no ui update.

instead of this

For r = 0 to 1000
Texfield1.text = r.ToText
Next

it could be a step via Timer Event

Texfield1.text = r.ToText
Method DoAStep(r As Integer)

alternate using a Thread which send ui updates

How do I get this?

Using Xojo 2022r4.1

1 Like