home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Form Designers And Code Windows

The last parts of the IDE that we’ll take a look at in our overview are form designers and code windows, which appear in the center of Figure 2.8. (The form designer displays the current form under design, complete with command button, and the code window displays the code for the Command1_Click() procedure.)


Figure 2.8  A form designer and code window.

Form designers are really just windows in which a particular form appears. You can place controls into a form simply by drawing them after clicking the corresponding control’s tool in the toolbox.

Code windows are similarly easy to understand: you just place the code you want to attach to an object in the code window (to open an object’s code in the code window, just double-click that object). There are two drop-down list boxes at the top of the code window: the left list lets you select the object to add code to, and the right list lets you select the procedure to add (all the methods the object supports appear in this list).

That completes our overview of the IDE. Let’s get into the actual meat of the chapter now, task by task.

Immediate Solutions

Selecting IDE Colors, Fonts, And Font Sizes

The Visual Basic IDE comes with all kinds of preset colors—blue for keywords, green for comments, black for other code, and so on. But as when you move into a new house, you might want to do your own decorating. Visual Basic allows you to do that. Just open the Options box by clicking the Options item in the Visual Basic Tools menu, and click the Editor Format tab, as shown in Figure 2.9.


Figure 2.9  Selecting IDE colors.

Here are the text items whose colors you can select:

  Normal Text
  Selection Text
  Syntax Error Text
  Execution Point Text
  Breakpoint Text
  Comment Text
  Keyword Text
  Identifier Text
  Bookmark Text
  Call Return Text

To set a particular type of text’s color and background color, just select the appropriate color from the drop-down list boxes labeled Foreground and Background, and click on OK. You can also set text font and font sizes in the same way—just specify the new setting and click on the OK button to customize the text the way you want it.

Aligning, Sizing, And Spacing Multiple Controls

Visual Basic is very...well...visual, and that includes the layout of controls in your programs. If you’ve got a number of controls that should be aligned in a straight line, it can be murder to have to squint at the screen, aligning those controls in a line down to the very last pixel. Fortunately, there’s an easier way to do it:

1.  Hold down the Ctrl key and click all the controls you want to align.
2.  Make sure you have one control in the correct position, and click that one last.

Sizing handles, the eight small boxes that you can grasp with the mouse to resize a control, appear around all the clicked controls. The sizing handles appear hollow around all but the last control you clicked, as shown in Figure 2.10; the last control you clicked has solid sizing handles, and it will act as the key control. The other controls will be aligned using this key control’s position.

To align all the selected controls to the same left, right, or center position of the key control, you continue with these steps:

3.  Select the Align item in the Format menu, opening the Align submenu, as shown in Figure 2.10.


Figure 2.10  Aligning new controls.

4.  Select the type of alignment you want in the Align submenu: align the left, the center, the right, the top, the middle, or the bottom edges of the controls with the key control.
5.  While the controls are still collectively selected, you can move them, if you like, as a group to any new location now that they are aligned as you want them.

To size all selected controls the same as the key control, follow Steps 1 and 2, and then continue this way:

3.  Select the Make Same Size item in the Format menu, opening that submenu, as shown in Figure 2.11.


Figure 2.11  Sizing new controls.

4.  Choose the appropriate item in the Make Same Size submenu to size the controls as you want them: matching the key control’s width, height, or both.

To space multiple controls vertically or horizontally, follow Steps 1 and 2 and then continue:

3.  Select the Horizontal Spacing or Vertical Spacing item in the Format menu, opening that submenu, as shown in Figure 2.12.


Figure 2.12  Spacing controls.

4.  To space the controls horizontally or vertically, select one of the items in the corresponding submenu:
  Make Equal—Sets the spacing to the average of the current spacing
  Increase—Increases by one grid line
  Decrease—Decreases by one grid line
  Remove—Removes spacing

The Design Time Grid

Spacing depends on grid lines. The grid is made up of the array of dots you see on a form at design time. This grid is to help you place controls on a form, and by default, controls are aligned to the grid (which means they are sized to fit along vertical and horizontal lines of dots). You can change the grid units (in twips) in the Options box when you click the General tab, as shown in Figure 2.13. (To open the Options box, select the Options item in the Tools menu.)


Figure 2.13  Modifying the grid settings.

Besides setting the units of the grid, you can also specify whether or not controls must be aligned to the grid by checking the Align Controls To Grid checkbox.

Setting A Startup Form Or Procedure

Visual Basic programs mean windows, right? Not necessarily. Visual Basic programs do not need to have any windows at all, in fact. That case is a little extreme, but there are times when you don’t want to start your program with code in a form. For example, you might want to display a flash screen when your program first starts, without waiting for the first (possibly complex) form to load, and then switch to the form when it does load.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.