juniorteacher Member Licensed User Longtime User Jul 1, 2015 #1 i use array to make button, how i identify that button i click? Code: Copy dim button(13) as button for i = 0 to 13 -1 but(i).Initialize("But") Activity.AddView(but(i),10%x + (i*11.5%x),14.5%y,11.5%x,8.3%y) next sub but(0)_click 'error in here msgbox("test","test") end sub please give me an example
i use array to make button, how i identify that button i click? Code: Copy dim button(13) as button for i = 0 to 13 -1 but(i).Initialize("But") Activity.AddView(but(i),10%x + (i*11.5%x),14.5%y,11.5%x,8.3%y) next sub but(0)_click 'error in here msgbox("test","test") end sub please give me an example
juniorteacher Member Licensed User Longtime User Jul 1, 2015 #2 if use but.tag i can't use function like but(0).enable =true Upvote 0
S sorex Expert Licensed User Longtime User Jul 1, 2015 #3 put the array number (i in your case) as tag and then you should be able to do Code: Copy sub but_click dim b as button b=sender log(b.tag) buttons(b.tag).enable=false end sub you better change the arrayname to buttons to avoid confusion Upvote 0
put the array number (i in your case) as tag and then you should be able to do Code: Copy sub but_click dim b as button b=sender log(b.tag) buttons(b.tag).enable=false end sub you better change the arrayname to buttons to avoid confusion
klaus Expert Licensed User Longtime User Jul 1, 2015 #4 Or simply: Code: Copy Sub But_Click Dim b as Button b = Sender b.Enable = false End Sub Upvote 0
S sorex Expert Licensed User Longtime User Jul 1, 2015 #5 indeed Klaus, since it's the same button anyway that's even shorter. Upvote 0
juniorteacher Member Licensed User Longtime User Jul 1, 2015 #6 sorex said: put the array number (i in your case) as tag and then you should be able to do Code: Copy sub but_click dim b as button b=sender log(b.tag) buttons(b.tag).enable=false end sub you better change the arrayname to buttons to avoid confusion Click to expand... buttons ??? i'm already change it, but pull down menu did show the option for enable klaus said: Or simply: Code: Copy Sub But_Click Dim b as Button b = Sender b.Enable = false End Sub Click to expand... i have 13 button and give tag name every button can it disable button from button tag name like Code: Copy Sub But_Click Dim b(13) as Button = sender Dim btnid as int = btn().tag ' error in here b(12).Enable = false ' error in here End Sub Upvote 0
sorex said: put the array number (i in your case) as tag and then you should be able to do Code: Copy sub but_click dim b as button b=sender log(b.tag) buttons(b.tag).enable=false end sub you better change the arrayname to buttons to avoid confusion Click to expand... buttons ??? i'm already change it, but pull down menu did show the option for enable klaus said: Or simply: Code: Copy Sub But_Click Dim b as Button b = Sender b.Enable = false End Sub Click to expand... i have 13 button and give tag name every button can it disable button from button tag name like Code: Copy Sub But_Click Dim b(13) as Button = sender Dim btnid as int = btn().tag ' error in here b(12).Enable = false ' error in here End Sub
S sorex Expert Licensed User Longtime User Jul 1, 2015 #7 it seems you don't really understand what you are writing there. look again at my example and the one from Klaus. It's all there. Upvote 0
it seems you don't really understand what you are writing there. look again at my example and the one from Klaus. It's all there.
juniorteacher Member Licensed User Longtime User Jul 1, 2015 #8 my question is simple, how to make array button with single click and disable the button from name tag Upvote 0
my question is simple, how to make array button with single click and disable the button from name tag
S sorex Expert Licensed User Longtime User Jul 1, 2015 #9 you will need to loop through the array and check the tags. if the right one passes you disable it. Upvote 0
juniorteacher Member Licensed User Longtime User Jul 1, 2015 #10 Code: Copy dim buttons(13) as button for i = 0 to 13 -1 buttons(i).Initialize("buttons") buttons(i).tag = i next sub buttons_click dim b as button = sender bid = b.tag b(btag).enable = false end sub i want buttons(0) can disable buttons(3) or buttons(5) Upvote 0
Code: Copy dim buttons(13) as button for i = 0 to 13 -1 buttons(i).Initialize("buttons") buttons(i).tag = i next sub buttons_click dim b as button = sender bid = b.tag b(btag).enable = false end sub i want buttons(0) can disable buttons(3) or buttons(5)
S sorex Expert Licensed User Longtime User Jul 1, 2015 #11 Code: Copy sub buttons_click dim b as button = sender bid = b.tag b.enable = false if bid=0 then buttons(3).enable=false buttons(5).enable=false end if end sub Upvote 0
Code: Copy sub buttons_click dim b as button = sender bid = b.tag b.enable = false if bid=0 then buttons(3).enable=false buttons(5).enable=false end if end sub
JordiCP Expert Licensed User Longtime User Jul 1, 2015 #12 I suppose the problem is that you are not declaring the buttons as Global variables. You must do so to be able to use them in the "buttons_click" event Code: Copy Sub Globals Dim buttons(13) as button end sub Sub Activity_Create(FirstTime as Boolean) for i = 0 to 13 -1 buttons(i).Initialize("buttons") buttons(i).tag = i next end sub Sub buttons_click dim b as button = sender bid = b.tag if bid=0 then buttons(3).enable=false buttons(5).enable=false endif end sub Upvote 0
I suppose the problem is that you are not declaring the buttons as Global variables. You must do so to be able to use them in the "buttons_click" event Code: Copy Sub Globals Dim buttons(13) as button end sub Sub Activity_Create(FirstTime as Boolean) for i = 0 to 13 -1 buttons(i).Initialize("buttons") buttons(i).tag = i next end sub Sub buttons_click dim b as button = sender bid = b.tag if bid=0 then buttons(3).enable=false buttons(5).enable=false endif end sub
juniorteacher Member Licensed User Longtime User Jul 1, 2015 #13 JordiCP said: I suppose the problem is that you are not declaring the buttons as Global variables. You must do so to be able to use them in the "buttons_click" event Code: Copy Sub Globals Dim buttons(13) as button end sub Sub Activity_Create(FirstTime as Boolean) for i = 0 to 13 -1 buttons(i).Initialize("buttons") buttons(i).tag = i next end sub Sub buttons_click dim b as button = sender bid = b.tag if bid=0 then buttons(3).enable=false buttons(5).enable=false endif end sub Click to expand... yes solved thanks very much.... that was true Upvote 0
JordiCP said: I suppose the problem is that you are not declaring the buttons as Global variables. You must do so to be able to use them in the "buttons_click" event Code: Copy Sub Globals Dim buttons(13) as button end sub Sub Activity_Create(FirstTime as Boolean) for i = 0 to 13 -1 buttons(i).Initialize("buttons") buttons(i).tag = i next end sub Sub buttons_click dim b as button = sender bid = b.tag if bid=0 then buttons(3).enable=false buttons(5).enable=false endif end sub Click to expand... yes solved thanks very much.... that was true