Finance

Charts

Statistics

Macros

Search

MultiPage and TabStrip with Excel VBA

The MultiPage control allows you to create multi-page dialog boxes. Page titles are displayed on tabs. Navigation between pages is done by clicking a tab.

You can create, rename, delete, or move a page of the MultiPage control manually by right-clicking the tab label and using the context menu.

The MultiPage object contains the Pages collection, which represents all the pages included in this object.
Table lists the main properties of the MultiPage object.

Table. Main properties of MultiPage

Property Description
Value Returns or sets the index of the active page. Indexing starts at 0.
MultiRow A Boolean property. If set to True, tab labels that do not fit in one row are displayed in multiple rows. If set to False, a scrollbar appears when tab labels do not fit in one row, allowing navigation between pages.
SelectedItem Returns the selected page.

The Pages collection consists of all Page objects, i.e., the pages of a MultiPage control.
The Pages collection has only one property, Count, which returns the number of elements in the collection.
Its methods are listed in Table.

Table. Methods of the Pages collection

Method Description
Add Creates a new page.
Clear Deletes all pages from the collection.
Remove Deletes a page from the collection.
Item Returns the page specified by index.

The TabStrip control creates multiple tabs in a dialog box and is functionally equivalent to a MultiPage control.
The TabStrip object contains the Tabs collection, which represents all the tabs.

The TabStrip object and the Tabs collection have the same properties and methods as the MultiPage object and the Pages collection.

Statistics and MultiPage
As an example of an application with multiple pages, let us improve the interface of the project from the earlier section “Determining statistical parameters of a range” .

Create a form with a MultiPage control:

  • On the first page (set the Caption property to Calculations), place a RefEdit control, a text box, and a button.
  • On the second page (set the Caption property to Parameters), place three checkboxes.

Use the Properties window to set the control properties as shown in Table.

Table. Property values set in the Properties window

Object Property Value
TextBox Name txtStat
Button Name cmdOK
Caption OK
CheckBox Name chkSum
Caption Sum
CheckBox Name chkMax
Caption Maximum
CheckBox Name chkMin
Caption Minimum

In the form module, type the required code. The project is ready.

The text box displays multi-line integrated statistics, with the parameters determined by the checkboxes on the Parameters page.

The text box is locked to prevent the user from editing the results.
In addition, the background color of the text box is set equal to the form’s background color.

As a result, the text box visually appears as an indented label within the form.

0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx