1. John Vanleeuwe
  2. PowerBuilder
  3. Thursday, 13 June 2019 02:11 AM

Hi all,

been coding for almost 20 hours straight , and i know my question is basic , but i just don't get the following issue.

i have created a dirlist function , based on a listbox in a window which works great.

to make it more dynamic , i wanted to create the listbox dynamically in my code so i won't need the window and the listbox anymore.


listbox lb_2
lb_2 = CREATE listbox
ls_folder = sle_1.text + "\" + "*.*"
result = lb_2.DirList(ls_folder,0)
messagebox("DIRLIST ", string(result))
aantal = lb_2.TotalItems()

messagebox("FILES FOUND",string(aantal))



why does my first messagebox results in being FALSE and my second one -1 if i create my listbox dynamically in my code ? must be such an easy answer :) i am just not seeing it ...





Who is viewing this page
Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 13 June 2019 02:36 AM
  2. PowerBuilder
  3. # Permalink

Hi John;

  You cannot create a visual control. Try the OpenUserObject() command instead.


Regards ... Chris

Awesome ! works like a charm.

Thanks again Chris !

  1. John Vanleeuwe
  2. Thursday, 13 June 2019 02:40 AM
Excellent news John ... Anytime! ?
  1. Chris Pollach @Appeon
  2. Thursday, 13 June 2019 02:56 AM
Hi John, "background" info: CREATE instantiates the PB objects - Open creates *both* PB objects and their Windows UI cousins.

BTW: It is hilarious to OPEN a window, immediately DESTROY it; … - and then discover what happens when user clicks on a button on the window!

DESTROY removed the PB object (hence, removed the clicked event script) albeit left the Windows UI window with all its controls still live and running.

Similar CREATE then CLOSE is no good either.

HTH /Michael

  1. Michael Kramer
  2. Thursday, 13 June 2019 23:24 PM
There are no comments made yet.

There are replies in this question but you are not allowed to view the replies from this question.