dkl
Full Member
Posts: 234
|
Post by dkl on Sept 4, 2021 3:06:41 GMT -5
listbox #1.1, Auto$(), [dummy3], x2, 50, w2,300 listbox #1.2, Lunch$(), [dummy3], x2, 50, w2,300 1.......24 listboxes all in same position and accessed by a relevant button [dummy3] WindowWidth = 500 WindowHeight = 45 UpperLeftX=705'int((DisplayWidth-WindowWidth)/2) UpperLeftY=485'int((DisplayHeight-WindowHeight)/2) BackgroundColor$ = "darkred" textbox #inf3.tb, 10, 10, 450, 25 stylebits #inf3.ok, _BS_DEFPUSHBUTTON, 0, 0, 0 button #inf3.ok, "OK", [OK3],UR, 5, 10, 30, 25 on error goto [OK3] open " " for Window_popup as #inf3 #1.1, "selection? selected$" '<----I SIMPLY WANT TO CHANGE THIS CODE ......... #1.1 to #1.2 or #1.3 etc #inf3.tb,selected$ wait [OK3] close #inf3 #1.1,"select 0" wait I simply want to able to change this short piece of code #1.1 to #1.2 or #1.3 etc, so that I can use the same routine to work with 24 listboxes instead of having to copy the whole code 24 times. I only need to change ONE digit! I've tried using variables and arrays in various forms, but that doesn't work. I could have 24 if/then statements, but that seems a bit silly. There must be a simple way? Is there an easy way to change the reference of the listbox extension?
|
|
|
Post by Chris Iverson on Sept 4, 2021 3:45:27 GMT -5
I think you can use handle variables for this.
hndl$ = "#1.1" #hdnl$, "selection? selected$"
|
|
|
Post by Rod on Sept 4, 2021 3:45:38 GMT -5
You need to use a handle variable. First of create a string that represents the handle, s$="#1.1" then use that in your code as a handle variable by prepending # So #s$ "selection? selected$"
You can amend s$ in a loop and so loop through 24 handles easily.
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Sept 4, 2021 4:35:22 GMT -5
Brilliant! Thanks you so much. I've not seen any mention of being able to do that anywhere. Probably couldn't see it for looking!!
|
|
|
Post by tsh73 on Sept 4, 2021 11:37:01 GMT -5
|
|