Android Question how can use for ... next

phd.khosravi

New Member
hi every one

Code: Copy
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim Button(9) As Button
   
End Sub

Code: Copy
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:

   
    For i = 1 To 8
    Button(i).Initialize("button"&i)
    Activity.AddView(Button(i),5%x,i*11%y,65%x,10%y)
    Button(i).Text="number"&i
    Button(i).Visible=False
    Next
   
End Sub

how can i use a code that One of the keys to the unseen
i mean like button3,button5,button7 be visible when u start program
 
Code: Copy
For i = 1 To 8
  Button(i).Initialize("button"&i)
  Activity.AddView(Button(i),5%x,i*11%y,65%x,10%y)
  Button(i).Text="number"&i
  Button(i).Visible=False
  if i = 3 then Button(i).Visible=true
  if i = 5 then Button(i).Visible=true
  if i = 7 then Button(i).Visible=true
Next
 
Upvote 0
Code: Copy
  if i = 3 then Button(i).Visible=true
  if i = 5 then Button(i).Visible=true
  if i = 7 then Button(i).Visible=true

or just:
Code: Copy
Button(3).Visible=true
Button(5).Visible=true
Button(7).Visible=true

another way:
If the buttons to show are in sequence (like 4,5,6,7) then you can use for...next loop
if the numbers are in geometric or arithmetic progression, then you can also use for...next loop with some additional efforts.
3,5,7 are in arithmetic progression (odds) but since the array is only 3 then you can just use the above example because you wouldn't save any code lines or time.
 
Upvote 0
Back
Top