B4J Question Name will increase by 1

red30

Well-Known Member
Licensed User
Longtime User
I have a lot of Pane: Pane1, Pane2, Pane3, Pane4, etc. And there is a sub-program where I have to change the height of each panel. Can I do this with the help of a subroutine?
B4X:
HeightPane(1,20%y)
HeightPane(2,10%y)
'etc

Sub HeightPane (a As Int,b As Int)
    Pane&"a".Height=b
End Sub
 

LucaMs

Expert
Licensed User
Longtime User
No.

Create an array of Panes and pass directly each pane to your routine, like:

B4X:
Dim MyPanes(10) As Pane
MyPanes(0) = Pane1
MyPanes(1) = Pane2
...
SetPaneHeight(MyPanes(5), 50dip)

Sub SetPaneHeight(P As Pane, Height As Int)
    P.Height = Height
End Sub
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
that would be the same as
B4X:
SetPaneHeight(Pane1, 50dip)
SetPaneHeight(Pane2, 40dip)

Sub SetPaneHeight(P As Pane, Height As Int)
    P.Height = Height
End Sub

u can also a List or Array as sub input parameter, so u can use for each there if there have the same properties.
or u can search the view objects by tag or id property with a little sub.
 
Upvote 0
Top