B4A Class dataLabel in a demo


Licensed User

I have a little app I am putting together - purely for learning purposes - and the layout has a couple of labels that are going to be updated on a regular (every second) basis .

It's not a lot of bother to have:

Label1.Text = "Some value: ~".Replace("~", 107)
<1 second later>
Label1.Text = "Some value: ~".Replace("~", 108)

but what I really wanted to do was write

Label1.DisplayString = "Some value: ~"


Label1.Data = 107
<1 second later>
Label1.Data = 108

and have the updating handled for me behind the scenes.

And so we arrive at the demo attached, which includes a class called dataLabel.

It has 3 settable properties:
ReplaceChar as Char ' (default = "~") the replaceable character in the
DisplayString as String ' the string / pattern to be displayed and
Data as String ' the data that replaces ReplaceChar
I've been programming in B4A for a few hours now, so the code is quite probably very green. I'd like to contribute it regardless, and if you take the time to check it out and have some suggestions for improvement , please let me know.

I've attached screenshots of pre- and post- [Set data] button click, so you can see how it works, in case my description does not make a lot of sense.