N NewB4a Member Licensed User Longtime User Jul 10, 2013 #1 I want to change the text of some buttons like btn1,btn2,bt3,...( 'btn' & nr) by the same sub. sub changeText(nr) ' changes the Text of Button btnnr end sub How to pass the number or anything else that defines the chosen button to the sub and change its text? Is there another simple way than using select case(nr=..) ?
I want to change the text of some buttons like btn1,btn2,bt3,...( 'btn' & nr) by the same sub. sub changeText(nr) ' changes the Text of Button btnnr end sub How to pass the number or anything else that defines the chosen button to the sub and change its text? Is there another simple way than using select case(nr=..) ?
klaus Expert Licensed User Longtime User Jul 10, 2013 #2 Unfortunately you don't give enough information. Where and how are the buttons defined with what names and what event names. Best regards. Upvote 0
Unfortunately you don't give enough information. Where and how are the buttons defined with what names and what event names. Best regards.
N NewB4a Member Licensed User Longtime User Jul 10, 2013 #3 The buttons are defined in Designer. Name and eventname can be anything if this should be useful. Upvote 0
GMan Well-Known Member Licensed User Longtime User Jul 10, 2013 #4 NewB4a said: The buttons are defined in Designer. Name and eventname can be anything if this should be useful. Click to expand... This are not REALLY more informations Upvote 0
NewB4a said: The buttons are defined in Designer. Name and eventname can be anything if this should be useful. Click to expand... This are not REALLY more informations
D devlei Active Member Licensed User Longtime User Jul 10, 2013 #5 Is this what you are trying to do? Code: Copy changeText(btn1, "Btn1's new text") Sub changeText(RelevantButton As Button, NewText As String) RelevantButton.Text = NewText End Sub Upvote 0
Is this what you are trying to do? Code: Copy changeText(btn1, "Btn1's new text") Sub changeText(RelevantButton As Button, NewText As String) RelevantButton.Text = NewText End Sub
chuck3e Active Member Licensed User Longtime User Jul 10, 2013 #6 NewB4a, Here's what I've done: Give all buttons the same event name (xxxxxx) Give each button a different tag sub xxxxxx_click Dim btnSender As Button Dim btnValue As Int btnSender = Sender btnValue = btnSender.Tag 'get button tag If btnValue = x Then 'check which button Buttonx.Text = "xyz" 'change text accordingly End If If btnValue = y Then Buttony.Text = "xyz" End If End Sub You could probably code the Ifs more efficiently but this gives you an idea of what I did. -C Upvote 0
NewB4a, Here's what I've done: Give all buttons the same event name (xxxxxx) Give each button a different tag sub xxxxxx_click Dim btnSender As Button Dim btnValue As Int btnSender = Sender btnValue = btnSender.Tag 'get button tag If btnValue = x Then 'check which button Buttonx.Text = "xyz" 'change text accordingly End If If btnValue = y Then Buttony.Text = "xyz" End If End Sub You could probably code the Ifs more efficiently but this gives you an idea of what I did. -C
Erel B4X founder Staff member Licensed User Longtime User Jul 11, 2013 #7 See this tutorial: Tick-Tack-Toe: working with arrays of views Upvote 0