[Solved] List Box addItem method not working

Creating and using forms
Post Reply
Hacker John
Posts: 25
Joined: Thu Dec 06, 2007 1:17 pm

[Solved] List Box addItem method not working

Post by Hacker John »

My code, fired from a button in a OOBase form is:

Sub Intialise(Event As Object)
'Sets up listbox contests
Dim Form As Object

Form=Event.Source.Model.Parent REM CODE BOUND TO FORM BUTTON

Dim lstMonths As Object 'Listbox
lstMonths = Form.getByName("lstMonth")

lstMonths.addItem ("One", 1)

End Sub


When I click the button, I get the messeage " BASIC Runtime Error. Property or method not found"

If I use "msgBox lstMonths.Name" It returns the listbox name OK but I can't seem to access its methods :cry: . Can anyone tell me where I'm going wrong - the docs don't seem to shed any light on it
Last edited by Hacker John on Sun Jan 13, 2008 12:45 pm, edited 1 time in total.
Hacker John
Posts: 25
Joined: Thu Dec 06, 2007 1:17 pm

Re: List Box addItem method not working

Post by Hacker John »

Cracked it. It appears that Form listboxes don't have the same methods as dialog listboxes. This code works:

lstMonths.stringitemlist()=Array("One", "Two", "Three")

This gives me the three entries in the parentheses as list items.

Using an array works too

Dim Arr (3) As String
Arr(0) = "one"
Arr(1) = "two"
Arr(2) = "three"

lstMonths.stringItemList()=(Arr)

Oh well, as you were! :D
Post Reply