|
Post by Ronnie on Sept 2, 2018 10:48:43 GMT -5
Hi
I have a screen with a populated listbox, and textbox. I want to add text to the textbox, based on the chosen listbox item. I think it could be done by identifying the listbox's item index, but I don't know how to find the index. Or maybe there is a better way. Any help or suggestions will be appreciated. Thank You...
|
|
|
Post by Rod on Sept 2, 2018 11:44:16 GMT -5
Stefan posted this previously which takes listbox selections and pastes to a textbox.
for i = 1 to 10 levels$(i) = right$(" "; i, 2); ": level "; i positions$(i) = str$(i) next
nomainwin WindowWidth = 285 WindowHeight = 370 UpperLeftX = (DisplayWidth - WindowWidth) / 2 UpperLeftY = (DisplayHeight - WindowHeight) / 2
listbox #m.lb, levels$(), [displayItem], 10, 10, 250, 200 textbox #m.tb, 10, 215, 250, 30 statictext #m.st, "Move item to position", 10, 254, 220, 25 textbox #m.tbPos, 230, 250, 30, 25 button #m.default, "Apply Changes", [applyChanges], ul, 10, 290, 250, 30
open "List Box Test" for window as #m #m "trapclose [quit]" #m "font courier_new"
#m.lb "singleClickSelect"
[noAction] wait
[displayItem] #m.lb "selection? theItem$" #m.lb "selectionindex? theIndex" #m.tbPos theIndex #m.tb mid$(theItem$, 5) #m.tb "!setfocus" wait
[applyChanges] #m.tb "!contents? theItem$" #m.tbPos "!contents? theNewIndex" #m.lb "selectionindex? theIndex"
if theNewIndex < 1 or theNewIndex > 10 then theNewIndex = theIndex
notice "Item not moved!"; chr$(13); "New index outside of bounds!" end if
if theNewIndex < theIndex then for i = theIndex-1 to theNewIndex step -1 theOldItem$ = mid$(levels$(i), 5) levels$(i) = right$(" "; i, 2); ": "; mid$(levels$(i+1), 5) levels$(i+1) = right$(" "; i+1, 2); ": "; theOldItem$ next end if if theNewIndex > theIndex then for i = theIndex to theNewIndex-1 theOldItem$ = mid$(levels$(i), 5) levels$(i) = right$(" "; i, 2); ": "; mid$(levels$(i+1), 5) levels$(i+1) = right$(" "; i+1, 2); ": "; theOldItem$ next end if levels$(theNewIndex) = right$(" "; theNewIndex, 2); ": "; theItem$
#m.lb "reload" #m.lb "selectindex 0" #m.tb "" #m.tbPos "" wait
[quit] close #m end
|
|
|
Post by Ronnie on Sept 2, 2018 12:42:37 GMT -5
Rod - Thank You...
|
|