S SpaceCow Member Licensed User Longtime User Jan 20, 2012 #1 Hi, Is it possible to call a object from a string? For example i have "button1" in a string, how do i transform this to call the object? Thanks!
Hi, Is it possible to call a object from a string? For example i have "button1" in a string, how do i transform this to call the object? Thanks!
klaus Expert Licensed User Longtime User Jan 20, 2012 #2 What exactly do you want to do ? Where does the string come from ? Are there different names ? etc. Best regards. Upvote 0
What exactly do you want to do ? Where does the string come from ? Are there different names ? etc. Best regards.
S SpaceCow Member Licensed User Longtime User Jan 20, 2012 #3 I have the buttons: button1, button2, button3 Now i want to call the buttons by the number so i have to merge the number with the text "button". Something like this: Sub Call_Button (BtnNumber As Int) Button+BtnNumber.Visible = true End Sub Upvote 0
I have the buttons: button1, button2, button3 Now i want to call the buttons by the number so i have to merge the number with the text "button". Something like this: Sub Call_Button (BtnNumber As Int) Button+BtnNumber.Visible = true End Sub
klaus Expert Licensed User Longtime User Jan 20, 2012 #4 If you defined the buttons in the Designer for each button enter 'Buttons' in the EventName field and enter the number of the button in the Tag field. If you defined the buttons in the code you must initialize them with Code: Copy Button1.Initialize("Buttons") Button1.Tag = 1 Button2.Initialize("Buttons") Button2.Tag = 2 ' etc. That means all buttons point to the same event routines. Then you have to use the code below in the event routine: Code: Copy Sub Buttons_Click Dim btn As Button ' defines a Button btn = Sender 'sets btn to the Button that raised the event Select btn.Tag ' btn.Tag is the Button number Case 1 . ' code for Button1 Case 2 . ' code for Button2 Case n . End Select End Sub You could have a look at page 39 in the Beginner's Guide. Best regards. Upvote 0
If you defined the buttons in the Designer for each button enter 'Buttons' in the EventName field and enter the number of the button in the Tag field. If you defined the buttons in the code you must initialize them with Code: Copy Button1.Initialize("Buttons") Button1.Tag = 1 Button2.Initialize("Buttons") Button2.Tag = 2 ' etc. That means all buttons point to the same event routines. Then you have to use the code below in the event routine: Code: Copy Sub Buttons_Click Dim btn As Button ' defines a Button btn = Sender 'sets btn to the Button that raised the event Select btn.Tag ' btn.Tag is the Button number Case 1 . ' code for Button1 Case 2 . ' code for Button2 Case n . End Select End Sub You could have a look at page 39 in the Beginner's Guide. Best regards.
S SpaceCow Member Licensed User Longtime User Jan 20, 2012 #5 That is not what i want. I just want to call an object (buttons, images, panels) from a string. In PHP i use this: $variable = "test"; echo ${"variable"}; Above outputs the string "test". Upvote 0
That is not what i want. I just want to call an object (buttons, images, panels) from a string. In PHP i use this: $variable = "test"; echo ${"variable"}; Above outputs the string "test".
agraham Expert Licensed User Longtime User Jan 20, 2012 #6 In Basic4android objects do not really have names so the parallel with PHp does not exist. You can legally do this Code: Copy Dim b1, b2, btemp As Button b1.Initialize("b1") b1.Tag = 1 b2.Initialize("b2") b2.Tag = 2 btemp = b1 b1 = b2 b2 = btemp msgbox(b1.Tag, "?????") Upvote 0
In Basic4android objects do not really have names so the parallel with PHp does not exist. You can legally do this Code: Copy Dim b1, b2, btemp As Button b1.Initialize("b1") b1.Tag = 1 b2.Initialize("b2") b2.Tag = 2 btemp = b1 b1 = b2 b2 = btemp msgbox(b1.Tag, "?????")
joseluis Active Member Licensed User Longtime User Jan 20, 2012 #7 I suppose that if you want to simulate that behaviour then you also could create a Map, with the names as keys, and the objects as values. Upvote 0
I suppose that if you want to simulate that behaviour then you also could create a Map, with the names as keys, and the objects as values.