REM ***** BASIC ***** Dim oDialog As Object Sub Main() Dim oLibContainer As Object, oLib As Object Dim oInputStreamProvider As Object Dim oDialogModel As Object Const sLibName = "ToolkitControls" Const sDialogName = "MultiPageDlg" REM load/get library and input stream provider oLibContainer = DialogLibraries oLibContainer.loadLibrary( sLibName ) oLib = oLibContainer.getByName( sLibName ) oInputStreamProvider = oLib.getByName( sDialogName ) REM create dialog control oDialog = CreateUnoDialog( oInputStreamProvider ) REM initialize dialog and controls Initialize() REM show the dialog oDialog.execute() End Sub Sub Initialize() Dim oDialogModel As Object Dim oNextButton As Object, oNextButtonModel As Object Dim oListBox As Object Dim oCheckBoxModel As Object Dim oOptionButtonModel As Object Dim oCurrencyFieldModel As Object Dim oNumericFieldModel As Object Dim oComboBox As Object, oComboBoxModel As Object Dim i As Integer Dim sName As String Dim sPizzas As Variant, sToppings As Variant Dim sCreditCards As Variant Dim sMonths As Variant Dim iCount As Integer REM dialog properties oDialogModel = oDialog.Model oDialogModel.Step = 1 REM next button properties oNextButtonModel = oDialogModel.NextButton oNextButtonModel.DefaultButton = True oNextButton = oDialog.getControl("NextButton") oNextButton.setFocus() REM enable/disable back button, set label of next button PageChanged() REM set control properties on dialog page 1 REM pizzas in list box oListBox = oDialog.getControl("ListBox1") sPizzas = Array("Margarita","Vegeterian","Ham & Pineapple","Mexican","Seafood") oListBox.addItems( sPizzas, 0 ) oListBox.selectItem( sPizzas(0), True ) REM extra toppings sToppings = Array("Extra Cheese","Corn","Onions","Olives") For i = 0 To 3 sName = "CheckBox" + i oCheckBoxModel = oDialogModel.getByName( sName ) oCheckBoxModel.Label = sToppings( i ) Next i REM default pizza size oOptionButtonModel = oDialogModel.OptionButton2 oOptionButtonModel.State = True REM currency field properties oCurrencyFieldModel = oDialogModel.CurrencyField1 oCurrencyFieldModel.ReadOnly = True oCurrencyFieldModel.DecimalAccuracy = 2 oCurrencyFieldModel.CurrencySymbol = "€" oCurrencyFieldModel.PrependCurrencySymbol = True REM calculate prize for default settings CalculatePrize() REM set control properties on dialog page 2 REM numeric field properties oNumericFieldModel = oDialogModel.NumericField1 oNumericFieldModel.DecimalAccuracy = 0 REM set control properties on dialog page 3 REM default payment method oOptionButtonModel = oDialogModel.OptionButton4 oOptionButtonModel.State = True REM credit cards in combo box oComboBox = oDialog.getControl("ComboBox1") sCreditCards = Array("Visa","Master/EuroCard","American Express") oComboBox.addItems( sCreditCards, 0 ) oComboBoxModel = oDialogModel.ComboBox1 oComboBoxModel.Text = sCreditCards(0) REM expiration month oListBox = oDialog.getControl("ListBox2") sMonths = Array("01","02","03","04","05","06","07","08","09","10","11","12") oListBox.addItems( sMonths, 0 ) oListBox.selectItemPos( Month(Date())-1, True ) REM expiration year oListBox = oDialog.getControl("ListBox3") For i = Year(Date()) To Year(Date()) + 4 iCount = oListBox.getItemCount() oListBox.addItem( Str( i ), iCount ) Next i oListBox.selectItemPos( 0, True ) End Sub Sub CalculatePrize() Dim oDialogModel As Object Dim oListBox As Object Dim oCheckBoxModel As Object Dim oCurrencyFieldModel As Object Dim Position As Integer Dim sName As String Dim i As Integer, nChecked As Integer Dim Prizes As Variant Dim Prize As Double REM prizes for medium size pizzas Prizes = Array( 4, 5, 6, 6, 7 ) REM get the position of the currently selected pizza oListBox = oDialog.getControl("ListBox1") Position = oListBox.getSelectedItemPos() Prize = Prizes( Position ) REM small pizzas are 1€ cheaper, large pizzas are 1€ more expensive oDialogModel = oDialog.Model If oDialogModel.OptionButton1.State = 1 Then Prize = Prize - 1 ElseIf oDialogModel.OptionButton3.State = 1 Then Prize = Prize + 1 End If REM get the number of extra toppings (0.5€ per extra topping) For i = 0 To 3 sName = "CheckBox" + i oCheckBoxModel = oDialogModel.getByName( sName ) If oCheckBoxModel.State = 1 Then nChecked = nChecked + 1 End If Next i Prize = Prize + nChecked * 0.5 REM set the value of the currency field oCurrencyFieldModel = oDialogModel.CurrencyField1 oCurrencyFieldModel.Value = Prize End Sub Sub PaymentMethodChanged() Dim oDialogModel As Object Dim bEnabled As Boolean REM get dialog model oDialogModel = oDialog.getModel() If oDialogModel.OptionButton4.State = 1 Then REM enable controls for payment by credit card bEnabled = True ElseIf oDialogModel.OptionButton5.State = 1 Then REM disable controls for payment by check bEnabled = False End If REM enable/disable controls With oDialogModel .Label11.Enabled = bEnabled .Label12.Enabled = bEnabled .Label13.Enabled = bEnabled .ComboBox1.Enabled = bEnabled .TextField6.Enabled = bEnabled .ListBox2.Enabled = bEnabled .ListBox3.Enabled = bEnabled .TextField7.Enabled = bEnabled End With End Sub Sub NextPage() Dim oDialogModel As Object REM get dialog model oDialogModel = oDialog.getModel() If oDialogModel.Step < 3 Then REM next page oDialogModel.Step = oDialogModel.Step + 1 REM enable/disable back button, set label of next button PageChanged() ElseIf oDialogModel.Step = 3 Then REM submit order SubmitOrder() REM hide dialog oDialog.endExecute() End If End Sub Sub PreviousPage() Dim oDialogModel As Object REM get dialog model oDialogModel = oDialog.getModel() If oDialogModel.Step > 1 Then REM previous page oDialogModel.Step = oDialogModel.Step - 1 REM enable/disable back button, set label of next button PageChanged() End If End Sub Sub PageChanged() Dim oDialogModel As Object Dim oBackButtonModel As Object Dim oNextButtonModel As Object Const sLabelNext = "Next >>" Const sLabelSubmit = "Submit" REM get dialog model oDialogModel = oDialog.getModel() REM get back button model oBackButtonModel = oDialogModel.getByName("BackButton") REM enable/disable back button If oDialogModel.Step = 1 Then oBackButtonModel.Enabled = False Else oBackButtonModel.Enabled = True End If REM get next button model oNextButtonModel = oDialogModel.getByName("NextButton") REM set label of next button If oDialogModel.Step = 3 Then oNextButtonModel.Label = sLabelSubmit Else oNextButtonModel.Label = sLabelNext End If End Sub Sub SubmitOrder() MsgBox "Your pizza will be delivered in 45 minutes." End Sub