Hi folks; been getting my feet wet with LibreOffice Basic; now trying to learn how to use a Dialog and having a rough time of it!!
One element of Dialog1 is a label (“lblChip”) that the user can click to identify that a retail transaction was carried out by credit card using the EMV chip method (instead of the increasingly popular contactless or the decreasingly popular “swipe” ).
This is the earliest stage and is just practice, so I just want to, say, change the background colors of each of the three labels (lblContactless, lblChip, lblSwipe) when one of them (lblChip) is clicked. (I know radio buttons make more sense for that but that brought on a whole lot of other messes for this beginner!!)
So in my Calc file “ledgercolumns.ods” Module1 opens with this
[code]Sub main()
Dim Dlg As Object 'Dialog1
Dim Chiplabel as Object 'will reference lblChip label in Dialog1
Dlg = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
Dlg.Execute()
End sub[/code]
And there is also
Sub chip_clicked()
Chiplabel = Dlg.getControl("lblChip")
Chiplabel.Model.BackgroundColor = #FCFC1E
End sub
And indeed Standard.Module1.chip_clicked is the macro assigned to the “Mouse button pressed” event for the “lblChip” control.
When I click on lblChip I get a BASIC runtime error “Object variable not set” higlighting the line
Chiplabel = Dlg.getControl("lblChip")
Hmmm… Dlg and Chiplabel were both Dim’ed as Objects when main() loaded, Dlg was loaded (and execute()'ed) just fine in the earliest runs (showing that main() did in fact execute), so how is Chiplabel failing to be set here?
(LibreOffice Basic is, at the start of things, looking to be about eighty thousand times more complicated than VBA!!! : / )