Android Question GOTO SUB.POSITION

Mr Blue Sky

Active Member
Licensed User
Longtime User
Hello everyone, today I use this and case it up to 100, i want delete the case if possible and going directly to the sub exemple PageSelect(Position) And I do not know how to do it

Sub PageSelect (Position As Int)

Select Position
Case "0"
'-------------

Case "1"
'-------------

Case "2"
'------------- etc ....

Case Else
'-------------

End Select
End Sub


i want if possible

Sub PageSelect (Position As Int)
GOTO SUB PageSelect(Position)
End Sub
 

wonder

Expert
Licensed User
Longtime User
Why don't you index your pages in an Array / Map / List and just call Page(x)?
 
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
Because I know how to do this with 4D but not with B4A and i no understand too much documentation to do this too
 
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
Sub ListViewSite_ItemClick (Position As Int, Value As Object)
RemoveViews
Activity.LoadLayout("AAAAAA")

TabStrip1.LoadLayout("Page1", "1111111")
TabStrip1.LoadLayout("Page2", "2222222")
TabStrip1.LoadLayout("Page3", "3333333")
TabStrip1.LoadLayout("Page4", "4444444")
TabStrip1.LoadLayout("Page5", "5555555")
TabStrip1.LoadLayout("Page6", "6666666")
TabStrip1.LoadLayout("Page7", "7777777")
' etc............
End Sub

Sub TabStrip1_PageSelected (Position As Int)

Select Position
Case "0"
TOTO

Case "1"
TITI

Case "2"
' etc.....

End Select
End Sub
 
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
Hi klaus,
Because have to much CASE and i want optimize my code. I want if possible go directly to the sub program if possible same this :

Sub TabStrip1_PageSelected (Position As Int)

"Goto the Sub program name" TOTO+Position

End Sub

Sub TOTO0
End Sub

Sub TOTO1
End Sub
 
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
With CallSub it possible same this ?

Sub TabStrip1_PageSelected (Position As Int)

CallSub TOTO(Main,MYSUB+Position)

End Sub
 
Upvote 0

Mr Blue Sky

Active Member
Licensed User
Longtime User
Today i use this code already :

Sub TabStrip1_PageSelected (Position As Int)
Select Position
Case "0"
MySUB0

Case "1"
MySUB1

End Select

End Sub


I want stop use this because have to much CASE and i no like my code

I want if possible one code same this for stop many CASE

Sub TabStrip1_PageSelected (Position As Int)
MySUB(Position)
End Sub

you understand now ?
I look in the documentation and i no find
 
Upvote 0
Top