ListBox in a Dialog GET SELECTED ITEM

LO 25.2.2.2
Calc
Macros for a ListBox in a Dialog
I can load the listbox but I cant get the ‘Result’ or ‘Selected Item’

Blockquote

‘’’’’’’’’’’ ListBox1

For x = 0 to 20
  	oSheet = ThisComponent.Sheets.getByName("Macros")   
  	oCell = oSheet.getCellByPosition(240, 1+x)
  	listVar = oCell.String
  	
    lstBox1 = oClockDialog.GetControl("ListBox1")
  	lstBox1.addItem(listVar,x)

Next

  	oCell = ThisComponent.Sheets(4).getCellByPosition(43,22) 
  	oCell.String = lstBox1.getSelectedItem()

Blockquote

Try with

lstBox1.SelectedValue

BASIC runtime error.
‘423’
Property or method not found: SelectedValue.

Sorry, I didn’t realize you were talking about Dialogs, so the getSelectedItem method should be fine.

In the code you show, it is missing oClockDialog.Execute() to display the Dialog, and then choose the item from the listbox.

Blockquote
Dim oClockDialog As Object

Sub ClockDialogShow
DialogLibraries.LoadLibrary(“Standard”)
oClockDialog = CreateUnoDialog( DialogLibraries.Standard.ClockDialog )
'X, Y, Width, Height, and a Flag allowing all parameters to be adjusted
oClockDialog.setPosSize(1350, 150, 400, 400, 5)

‘’’’’’’’’’’ View DateField1
'dim oDateField1 as object
'D=Now()

'oDateField1=oClockDialog.GetControl(“DateField1”)
'REM This gives a runtime error “Object variable not set”
’ oDateField1.Setdate(D)
'REM This has no effect on the value of the Date field in the control
’ oDateField1.Date.Day=Day(D)
'oDateField1.Date.Month=Month(D)
'oDateField1.Date.Year=Year(D)

'oDateField1.View.setText(D)

‘’’’’’’’’’’ ListBox1
For x = 0 to 20
oSheet = ThisComponent.Sheets.getByName(“Macros”)
oCell = oSheet.getCellByPosition(240, 1+x)
listVar = oCell.String

		lstBox1 = oClockDialog.GetControl("ListBox1")
		lstBox1.addItem(listVar,x)
Next

		oCell = ThisComponent.Sheets(4).getCellByPosition(43,22) 
		oCell.String = lstBox1.getSelectedItem()
    	'oCell.String = lstBox1.SelectedValue
    	'oCell.String = lstBox1.SelectedText()

oClockDialog.Execute()

End Sub

Blockquote

hi,
sorry i’m having some trouble with this block quote thing
The Form itself is working. just having trouble with the result from the Listbox/combobox
(I also can’t figure out how to fill a datefield)

ea

Insert “oClockDialog.Execute()” before “oCell.String = lstBox1.getSelectedItem()”

you got it! Thankyou