vel05.htm
来自「简单的说明如何使用VB,非常适合初学使用者,而且是用图表来解说的」· HTM 代码 · 共 2,465 行 · 第 1/4 页
HTM
2,465 行
<BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 ><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>MultiLine</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True, the text box can display more than one line of text. If False (the default), the text box contains a single, and often long, line of text. The text can contain a carriage return.</FONT></TABLE><TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 ><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Name</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The name of the control. By default, Visual Basic generates the names Text1, Text2, and so on, as you add subsequent text boxes to the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>PasswordChar</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If you enter a character, such as an asterisk (*) for the PasswordChar, Visual Basic does not display the user's text but instead displays the PasswordChar as the user types the text. Use text boxes with a PasswordChar set when the user needs to enter a password and you don't want others looking over his shoulder to peek at the password. Figure 5.2 shows a password-entry form that uses an asterisk for the password character. Even though the text box receives the user's actual typed characters, the screen displays only the PasswordChar typed.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>ScrollBars</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Set to 0 (the default) for no scroll bars, 1 for a horizontal scroll bar, 2 for a vertical scroll bar, or 3 for both kinds of scroll bars.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>TabIndex</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The focus tab order begins at 0 and increments every time you add a new control. You can change the focus order by changing the value of the TabIndex of the control. No two controls on the same form can have the same TabIndex value.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>TabStop</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True, the user can press Tab to move the focus to this label control. If False, the label control cannot receive the focus.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Tag</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Not used by Visual Basic. The programmer can use it for identifying comments applied to the text box.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Text</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The initial value that the user sees in the text box. The default value is the name of the control. The value continues to update as the user enters new text at runtime.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Top</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The number of twips from the top edge of a text box to the top of the form.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Visible</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>True or False, indicating whether the user can see and, therefore, use the text box.</FONT><TR><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>Width</FONT><TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>The width of the text box in twips.</FONT></TABLE><P><B> <A HREF="05vel02.gif">Figure 5.2. The password character appears </B><B>instead of the characters that the user types.</A></B><BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Warning: </B>Table 5.3 lists only those text box properties that you can initialize and change in the Properties window. Other text box properties that you can change using Visual Basic code are available only at runtime.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P><FONT COLOR="#FF8000"><B><I>Review: </I></B></FONT>The text box control enables you to display default values and to accept the changes and additions that the user makes to those values when he enters text from the keyboard. Once the user enters text in a text box control, you can check the Text property to access that text.<BR><BR><A NAME="E68E45"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>Setting Properties</B></FONT></CENTER></H3><BR><P><FONT COLOR="#FF8000"><B><I>Concept: </I></B></FONT>The Properties window makes its easy for you to set properties when you place controls on the form and build your application.<BR><P>The Properties window contains a list of every property that you can specify at <I>design time</I>. For example, there are 25 command button properties—refer to Table 5.1 for the complete list—that you can set when you place a command button on a form at design time. You can also read and change many of them when you run the program. Three properties that you can set at runtime through code are not available at design time. There are additional properties that you can set at runtime through code but not set at design time.<BR><P>The Properties window offers several ways of setting property values. Figure 5.3 shows the Properties window for a label control. Notice that the Properties window contains a scrolling list of properties available at design time for labels, a data entry and dropdown list for setting property values, and a dropdown list for selecting another control's properties.<BR><P><B> <A HREF="05vel03.gif">Figure 5.3. The Properties window offers you </B><B>several ways to change property values.</A></B><BR><P>As you found out in the previous unit, you can change a property value by clicking the property’s row in the Properties window and entering a new value. The window’s data entry text box receives the new property as you type the name. If you clicked the Name property and typed a new name, you would see the name in the data-entry text box.<BR><P>The Properties window also offers you multiple-choice selections from which to choose if a property can assume a limited number of values. For example, the MousePointer property can hold the only values 0-Default through 7-Size NS. These are the various shapes in which the mouse can appear. Instead of typing one of these values, simply click the MousePointer property and then the down arrow that opens the data-entry text box's dropdown list, shown in Figure 5.4. You can select one of the values from the list without having to type a value.<BR><P><B> <A HREF="05vel04.gif">Figure 5.4. Visual Basic offers a choice of </B><B>property values.</A></B><BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Note: </B>You don't have to select a control first to see its properties in the Properties window.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>Some programmers prefer to place several controls on a form before they set any property values. Once you place several controls on the form, each control has its own set of properties that you can set from the Properties window. Use the window's control dropdown selection box to display all the controls in the application, as shown in Figure 5.5. Select from the list of controls that drops down to see the control's property settings appear in the Properties window.<BR><P><B> <A HREF="05vel05.gif">Figure 5.5. Select the control whose properties </B><B>you want changed.</A></B><BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Tip: </B>The Properties window’s dropdown list of controls shows the type and the name of each control.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><I>Definition: </I>A <I>palette</I> is a set of colors from which you choose.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>When you set a color property, such as a label's BackColor property, you can type the hexadecimal color value, but it is much easier to select the color from a palette of colors that Visual Basic displays for you. If you clicked the BackColor property of a control such as a label, the Properties window data-entry text box changes to ellipses (...) instead of the arrow that normally accompanies a dropdown box. When you click the ellipses, Visual Basic displays a color selection palette like the one shown in Figure 5.6. Click one of the palette's colors to select it for the BackColor property. Visual Basic assigns the appropriate color hexadecimal value to match the color that you select.<BR><P><B> <A HREF="05vel06.gif">Figure 5.6. Select a color from the palette of </B><B>colors.</A></B><BR><P><FONT COLOR="#FF8000"><B><I>Review: </I></B></FONT>The Properties window offers all kinds of helpful shortcuts that you can use when you set property values for your form’s controls. You can move from control to control and set properties along the way by choosing the control from the Properties window. You also can select a value for properties that is based on a fixed list of possible values.<BR><BR><A NAME="E68E46"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>Homework</B></FONT></CENTER></H3><BR><BR><A NAME="E69E38"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>General Knowledge</B></FONT></CENTER></H4><BR><OL><LI>What is meant by <I>focus</I>?<BR><BR><LI>What is the focus order?<BR><BR><LI>Which property controls the focus order?<BR><BR><LI>Which property is common for all controls and names the controls?<BR><BR><LI>True or false: You can set or change all properties at program design time.<BR><BR><LI>True or false: Only one control can have the focus at any one time.<BR><BR><LI>If a property can accept only a limited range of values, which text file holds descriptions for those ranges?<BR><BR><LI>What is an icon?<BR><BR><LI>What meant by the measurement term <I>point</I>?<BR><BR><LI>What is a palette?<BR><BR><LI>Which of the following can the user enter in text box controls?<BR><BR><OL TYPE=A><LI>Numbers<BR><BR><LI>Letters<BR><BR><LI>Special characters<BR><BR><LI>All of the above<BR><BR></OL><LI>Which property disables a text box control from triggering event procedures?<BR><BR><LI>What is the range of values that the Alignment property can hold?<BR><BR><LI>True or false: You often must set most of the property values every time you place a control on a form.<BR><BR><LI>What is a carriage return character?<BR><BR><LI>What does <I>DDE</I> stand for?<BR><BR><LI>True or false: A control can appear on the form but not be seen by the user.<BR><BR><LI>Which four properties available for most controls describe the two measurement indicators to the right of the toolbar?<BR><BR></OL><BR><A NAME="E69E39"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Write Code That...</B></FONT></CENTER></H4><BR><OL><LI>What is the best control for titles and instructions?<BR><BR><LI>Which text box property setting would you use for a secret message that the user must enter?<BR><BR><LI>Suppose that you were writing a Visual Basic program that needs to perform a specific task when the user presses Esc. Which property do you have to set?<BR><BR></OL><BR><A NAME="E69E40"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Find the Bug</B></FONT></CENTER></H4><BR><OL><LI>Julie is unhappy. She just began programming in Visual Basic so she can use some help to overcome her frustration. Julie places all her controls on the form before setting property values for the controls. The only problem that Julie has is that she thinks she must close the Properties window, highlight another control, and display the Properties window once again to set that control's property settings. Show Julie a better way.<BR><BR></OL><BR><A NAME="E69E41"></A><H4 ALIGN=CENTER><CENTER><FONT SIZE=4 COLOR="#FF0000"><B>Extra Credit</B></FONT></CENTER></H4><BR><OL><LI>Even though only one control at a time can have the focus, there is a property that can make the user think that a text box still has the focus when the focus is really elsewhere. What is the name of this text box property?<BR><BR></OL><P>Which text box control property works the most like the Caption property of a command button or label?<BR><P ALIGN=LEFT><A HREF="velp02.htm" TARGET="_self"><IMG SRC="purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A><A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A><A HREF="index.htm" TARGET="_self"><IMG SRC="purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A><A HREF="vel06.htm" TARGET="_self"><IMG SRC="purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?