Difference between revisions of "The Basics of VB6"
m |
|||
Line 1: | Line 1: | ||
These notes can be organized later. | These notes can be organized later. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== TabStrip Control === | === TabStrip Control === | ||
Line 128: | Line 78: | ||
Set LoopTime = New TimerClass: tmrDisconnect.Enabled = True | Set LoopTime = New TimerClass: tmrDisconnect.Enabled = True | ||
End Select | End Select | ||
− | |||
− | |||
− | |||
− | |||
=== Public Declarations === | === Public Declarations === |
Revision as of 10:50, 2 February 2008
These notes can be organized later.
Contents
TabStrip Control
Tabs are not containers! In design time you cannot just select a tab and drop a control on it, assigning a different control to each tab. It just isn't how tabs work.
You must trap the click event and determine which tab is being clicked.
Private Sub TabStrip1_Click() SelectedTab = TabStrip1.SelectedItem.Index End Sub
Setting the default tab
Private Sub Form_Load() 'default to first tab (note: indexing starts at 1 - this is how control is designed) TabStrip1.Tabs(1).Selected = True End Sub
Another Example
Private Sub TabStrip1_Click TabFrame(TabStrip1.SelectedItem.Index-1).Zorder 0 End Sub
Tabs That Are Containers:
If you wish to use tabs that are containers, look at SStab, which is in the component Microsoft Tabbed Dialog Control 6.0 (SP5). The .OCX is TABCTL32.ocx.
Adding Controls to Tabs
- Add and setup the tabstrip control with the number of tabs desired.
- Add 1 frame control for each tab. Make them each the same height and width. Name each with something like fraFirstTab, fraSecondTab, etc.
- Add the controls that you want to appear when the first tab is clicked to fraFirstTab. Repeat this for each remaining tab (use fraSecondTab for the second tab, etc.)
- set the Top and Left properties for all frames to the same value so that it appears within the tabstrip control. You may need to adjust the tabstrip height and width to accomidate this.
- Set the Visible property for all frame to True.
- Select fraFirstTabe and insure that it is on top of the ZOrder. Do this by Selecting Format -> Order and see what options are available. If "Bring to Front" is grayed out and "Send to Back to in black, then its ok, If not, click "Bring to Front".
- Add the following code to the Click event procedure of your tabstrip control:
Select Case TabStrip1.SelectedItem.Index Case 1: fraFirstTab.ZOrder 0 Case 2: fraSecondTab.ZOrder 0 ' add 1 CASE statement for each tab. Change the frame control name to correspond to the tab that has been selected. End Select
- 8. What SHOULD happen is the the frame that corresponds to the tab selected is moved to the top of the ZOrder, overlaying the other frames.
Select Case (Switch)
CASE in Visual BASIC does not "fall through" like in C.
Select Case Button.Key Case "ListCache" mnuListCache_Click Case "Refresh" mnuRefresh_Click Case "simmode" cmdSimMode_Click End Select
Select Case tcpClient.State Case 0 tcpClient.RemoteHost = cboRemoteHost SessionConnect Case 7 lblStatus.Caption = "Connected" Case 9 lblStatus.Caption = "Connection Error" End Select
Case based on more than one condition
Select Case True Case strMessage Like "*OK*" And lblStatus.Caption = "Connected" blnReceivedAll = True Case strMessage Like "*OK*" And lblStatus.Caption = "retrieving." lblStatus.Caption = "retrieving.." blnReceivedAll = True Case Else Set LoopTime = New TimerClass: tmrDisconnect.Enabled = True End Select
Public Declarations
Public strCurrentTool As String
Public fMainForm As frmQAB
Public cn As ADODB.Connection
Public rsCompanies As ADODB.Recordset
Public Const dbtContact = "contact"
StatusBar Control
Visual BASIC 6.0 Status Bar Control (MFC status bar control) is an ActiveX control. To enable select "Microsoft Common Control" option from the component dialog box. A StatusBar control provides a window, usually at the bottom of a parent form, through which an application can display various kinds of status data. The StatusBar can be divided up into a maximum of sixteen Panel objects that are contained in a Panels collection.
- Right-click on the Status Bar to bring up the Properties for the control
- Select the Panels Tab.
- Use the Index tab and the Insert Panel Button to add additional panels.
- Use the Style Drop-down list box to select a different type of information to appear in a panel.