The Change event occurs when the currently selected tab has changed. The BeforeChange event occurs when the currently selected tab is about to change.
Sub TabStrip_Change
Sub TabStrip_BeforeChange(Cancel?)
BeforeChange is generated before Change and can be used to cancel the tab change by setting Cancel? to True. Inside BeforeChange the SelectedItem property (or SelectedIndex) still specifies the current tab.
When a new tab is selected Change is invoked. Use SelectedItem or SelectedIndex to obtain the current Tab object.
Ocx TabStrip tbs = "", 0, 0, 220, 25
Ocx Option opt(1) = "Option Box 1", 10, 40, 100, 14 : tbs.Add 1, , "Option 1"
Ocx Option opt(2) = "Option Box 2", 10, 60, 100, 14 : tbs.Add 2, , "Option 2"
Ocx Option opt(3) = "Option Box 3", 10, 80, 100, 14 : tbs.Add 3, , "Option 3"
Ocx Option opt(4) = "Option Box 4", 10, 100, 100, 14 : tbs.Add 4, , "Option 4"
opt(1).Value = 1
Do : Sleep : Until Me Is Nothing
Sub tbs_Change
opt(tbs.SelectedIndex).Value = 1
End Sub
Sub tbs_BeforeChange(Cancel?)
If MsgBox("Tab change allowed?", MB_OKCANCEL) = IDCANCEL
Cancel? = True
EndIf
EndSub
{Created by Sjouke Hamstra; Last updated: 24/09/2014 by James Gaite}