Get the selected value from a listbox inside of a dialog

Version: 7.5.9.2 (X86_64) / LibreOffice Community
Build ID: cdeefe45c17511d326101eed8008ac4092f278a9
CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: pt-BR (pt_BR.UTF-8); UI: pt-BR
Calc: threaded

Sup, I’m trying to create a dialog box to serve as a simple floating form, I added a listbox inside this dialog, and now I want to get the value that the user selected, in order to store this data, I’m trying to get it like this:

Dim oDialog AS Object
Public payment

Sub OpenDialog
	DialogLibraries.LoadLibrary("Standard")
	oDialog = CreateUnoDialog( DialogLibraries.Standard.getByName("PaymentRecorde") )
	
	payment = oDialog.Model.getByName("payment")

	oDialog.Execute()
	oDialog.Dispose()
End Sub


Sub CloseDialog()

paymentway = payment.selectedvalue
msgbox(paymentway)
oDialog.EndExecute()

End sub

I want the selected value to be inside the variable, like: "credit card", but the way I’m doing by using the .selectedvalue function, isn’t working, it gives me an error saying that this method doesn’t exist.

The values displayed in the listbox were written by me in the property menu, in the list entry option like this:

Debit card
Credit card
Money

or as theyre displayed:

"Debit card";"Credit card";"Money"

Is there another way to get the value different from selectedvalue method? Thanks

Try this way:

Sub CloseDialog()
  Dim oControl As Object, paymentway As String
  oControl=oDialog.getControl("payment")
  paymentway = oControl.selectedItem
  msgbox(paymentway)
  oDialog.EndExecute()
End Sub 
1 Like