Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

LibreOffice Basic - Getting all items listed in a ComboBox

Ladies and Gents,

I am having the most difficult time attempting to find any explanation on how I can access each item within a ComboBox.

I have created my own custom form (named "NewTransaction") using LibreOffice Basic (v5.0.3.2). On it, I have a combobox named "cmbxCategory". In my code module, I have the following code:

Function ShowDialog_NewTransaction
Dim dialogBox_NewTrans As Object

Set dialogBox_NewTrans = LoadDialog("Standard", "NewTransaction")

With dialogBox_NewTrans
    With .GetControl("cmbxCategory")
        .addItem("Food", 0)
        .addITem("Drinks", 1)
        MsgBox .ListEntries(0)
    End With

End With

End Function

What I am ultimately after is to be able to call, at any time, the nth item in a combobox and store it into a string. Perhaps, I will want to assign "text" to be equal to the first item in the list. I understand that I may go out of bounds. Obviously, I receive an error on the MsgBox .ListEntries(0) line.

How can I set the chosen text to be equal to the nth item in the combobox list? How can I determine the number of elements in the combobox list so that I can prevent going out of bounds?

Also, I am considered an Expert at my job with regard to MS VBA, but for LibreOffice, I can't seem to find any good documentation showing all available method calls, in this case, for a combobox. What would you recommend I reference when it comes to looking for various method calls?

Thank you for all your help!