Some String question and help

pluton

Active Member
Licensed User
Longtime User
OK
I have label in my activity and i want that label show some text.

Example:

Dim lb As Label
Dim t1,t2,t3 As String
Dim i As Int
i = 1 'later i will change value of i

t1 = "First"
t2 = "Second"
t3 = "third bla bla"

lb.Text = ("t" &i)

And result is t1

How will i make that result is: First, Second or Third ???? :sign0104:
 

pluton

Active Member
Licensed User
Longtime User
Thanks Erel

I need that "i" because i will make some random words.
If i stuck here I will ask again for help :)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I'm afraid you misunderstoud Erels post.
With arrays the numbering begins with 0.

B4X:
Dim lb As Label
Dim t(3) As String
Dim i As Int
i = 1 'later i will change value of i
 
t(0) = "First"
t(1) = "Second"
t(2) = "third bla bla"
 
lb.Text = t(i)

or as Erel did, he used number instead of t like you and filled the array using the Array keyword.
B4X:
Dim t() As String
t = Array As String ("First", "Second", "third bla bla")
...
lb.Text = t(i)

Best regards.
 
Upvote 0
Top