Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!:Drawing Your Way To Success
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!
(Publisher: The Coriolis Group)
Author(s): Peter G. Aitken
ISBN: 1576102815
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
A designer, on the other hand, provides a visual design window within the Visual Basic development environment. The Visual Basic forms designer is included by default in all versions of the development environment. The Professional and Enterprise editions of Visual Basic provide additional designers.
Properties Make The Object
Every Visual Basic object has a set of properties that controls how it looks and behaves. This is true even of insertable objects, although their property sets are relatively small, because so much of their behavior is determined by the parent application and not by Visual Basic. Rather than just talking about properties, lets create a simple Visual Basic project that demonstrates how they work. This program will display text in a Text Box, permitting the user to change the size of the Text Box and the color of the text.
Starting To Design The Interface
This project is designed specifically to illustrate the relationships between objects, properties, and code. It consists of a single dialog box with eight controls. Ill be honest and admit that the program does not do anything useful, but I believe it will be a valuable learning tool. To start, fire up Visual Basic; if it is already running, select New from the File menu. Choose Standard EXE from the New Project dialog box. The first control well place on the form is a Text Box. Using the techniques you learned earlier in this chapter, place a Text Box in the upper left corner of the form. The exact size doesnt matterperhaps two grid units high by eight units wideyou can always adjust it later. There are other controls to be placed, but first lets set the properties for the Text Box that we just added.
Changing The Text Property
Make sure that the Text Box is selected, then take a look at the Properties window. If this window is not displayed, press F4. The Properties window displays the properties of the selected object, with the objects name (that is, its Name property) displayed in the title bar. Just below the title bar is a box that displays the objects name and its type. This box is like a Visual Basic Combo Box controlyou can click on the arrow at the right end of the box to see a list of all the controls on the current form. Select a control by choosing it from the list, just as if you had clicked on it on the form.
The list in the Properties window lists all of the controls properties, either in alphabetical order (on the Alphabetic tab) or organized by category (on the Categorized tab). The property names are in the left column, and the property values in the right column. You use the scroll bar to display different properties, then select a specific property by clicking on it. The area at the bottom of the Properties window displays a brief description of the highlighted property. Scroll until the Text property is visibleon the Categorized tab, it is listed in the Misc section. The default value for this is Text1, as shown in Figure 3.4. The Text property of a Text Box specifies the text that is displayed in the control.
We need to change the Text property of this control. Follow these steps:
1. Scroll the Properties list to bring the Text property into view.
2. Double-click on the Text property name to highlight the property value in the right column.
3. Type in the new text. I used Visual Basic, but you are welcome to use any short phrase you like. The text you type will replace the highlighted text.
4. Press Enter, select another property, or click on the form to end editing. If you want to cancel your changes and reset the property to its original value, press Esc.
Notice that the new property is reflected not only in the Properties window, but also in the Text Box control on the form.
Suppose you made a typing error while entering the Text property. Do you have to go back and retype the whole thing? Not at all. If you click on the property value in the right column of the Properties window, Visual Basic will display an editing cursor at the end of the text, allowing you to edit the text using the regular editing keys. Here are brief descriptions of each of the keys:
The left and right arrows move the cursor one character at a time.
Ctrl+Left arrow and Ctrl+Right arrow move the cursor one word at a time.
Figure 3.4 Changing the Text Box controls Text property.
The Home and End keys move the cursor to the start or end of the text.
The Del key erases selected text or the character to the right of the cursor.
The Backspace key erases the character to the left of the cursor.
New text is inserted at the cursor.
To select text, drag over it with the cursor.
Changing The Font Property
Next, well change the Text Boxs Font property. As you can guess, this property determines the font used for the text in the control. Scroll the Properties list to bring the Font property into view and click once on the property name. A small button with three dots displays next to the current font value. Click on the button to display the Font dialog box, which is shown in Figure 3.5. You can also double-click on the Font property name to go directly to the dialog box. Select from the Font, Font Style, and Size lists to specify the font you want, then click on OK. I suggest using a font 12 points in size. The new font is reflected immediately in the Text Box on the form. Depending on the size of the font you selected, you may need to increase the size of the Text Box to display all of the text.
Adding The Other Controls
Now that the first control is complete, well add all of the remaining controls and then change their properties as needed. We need three Command Buttons, three Option Buttons, and one Frame.
What is the Frame control for? Think back to our discussion of Option Button controls. I mentioned that only one Option Button in a group can be set to on at any time. The obvious question is, How does one define a group of option buttons? By placing them in a Frame, thats how. If you want more than one group of Option Buttons on a form, you need one Frame for each group.
Figure 3.5 Changing the controls Font property.
Placing Option Buttons in a Frame requires a specific technique. If you add some Option Buttons to a form, add a Frame, and finally drag the Option Buttons onto the Frame, they will certainly appear to be in the Frame, but Visual Basic will not treat them as a group. To have a set of Option Buttons treated as a group, you have to put the Frame on the form first, then draw the Option Buttons within the Frame. Here are the steps required:
1. In the lower left corner of the form, place a Frame large enough to hold three Option Buttons.
2. Click on the Option Button icon in the toolbox.
3. Point at the interior of the Frame and drag to place the Option Button.
4. Repeat Steps 2 and 3 to place the additional Option Buttons.
Next, add the three Command Buttons, placing them in the lower right area of the form. At this point, the form will look more or less like Figure 3.6.
Before changing the properties of these newly added controls, we should save the project. Select Save Project from the File menu. Because the project and form files have not been given names yet, Visual Basic will prompt you for names. I used Properties Demo for the project and Properties for the form, but you can assign other names if you like.
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. Read EarthWeb's privacy statement.
Wyszukiwarka
Podobne podstrony:
Iracki żołnierz zabił dwóch żołnierzy USA (03 05 2009)PM1 03 05OST D 05 03 05 Nawierzchnia z betonu asfaltowegoAmerykański wywiad rozpracowuje Smoleńsk Nasz Dziennik, 2011 03 05Artykuł Dolar międzynarodowy (2007 03 05)FPJ wyk 03 05ZL2 03 05TI 03 05 03 B pl(1)2007 03 05 gazeta prawna03 05TI 03 05 19 T B pl(1)więcej podobnych podstron