170 likes | 271 Views
Chapter 3. Building an Application in the Visual Basic .NET Environment. Making an Application – Interface Design. Once you have analyzed the problem and understand the needs, the next step is to design the user interface ( UI ).
E N D
Chapter 3 Building an Application in the Visual Basic .NET Environment
Making an Application –Interface Design • Once you have analyzed the problem and understand the needs, the next step is to design the user interface (UI). • The UI is the way the a program accepts data and instructions from the user and produces results. • A Graphical User Interface (GUI) provides visual cues such as a menu, a button, or small pictures (called icons) to help the user enter data and give instructions to the computer.
MORE NEW TERMS • A control is said to have focus when it is selected on the screen. • Usually it’s easy to see which object has focus during a run. You’ll see the cursor blinking or a box around the button or control. • You can set the focus to any object via code or by setting properties. • Properties--characteristics, or attributes, of a control, such as its color or the text that displays on top of it. • Properties window -located on the right hand side of your screen. You go there to change properties during design time
Using the Property Window • Object Box – displays the name of the currently selected object or control. • Property List – displays the set of properties for the object named in the Object Box. • Toolbar • Categorized button – properties are grouped by categories such as behavior or appearance. • Alphabetic button – all the properties are displayed alphabetically. • Description Pane – displays information about what the selected property is for. • It is not necessary to set every property for controls added to your forms. VB.Net assigns default values for each property.
NEW PROPERTIES -- FORM • StartPosition Property (form)– specifies the position where the application will display on run. • The default value is WindowsDefault. • Please switch to CenterScreen for my applications. • Text Property (form)– allows you to set the title for a form. • FormBorderStyle Property – controls the appearance of the border of a form. • Default value is Sizable. User can drag and resize the application at run. • Please switch to FixedDialog for my applications. • BackColor and ForeColor – sets the background and foreground colors for the form.
NEW TERMS • Design time - the time during which you build an application. • Run Time-- the time during which you use a program for its intended purpose. • Controls-- objects that you can add to your form.They are found on VB.Net’s Toolbox • Label control -- displays text on the form that cannot be altered by the end user. • Textbox control--displays text on the form that can be altered by end user • Button control--used by the user to initiate actions called events. • NumericUpDown control – used to display or allow users to enter numbers on a form. Cuts down on user’s ability to screw things up.
SOME IMPORTANT PROPERTIES • Name-- allows you to rename the object to something that makes more sense. • Text- allows you to change the words that show up on the control itself. (or on the title bar of the form!). • Read-Only--Makes it impossible for the end user to edit the text in that box. • Tab Index--Allows the programmer to control the order in which the control gets the focus when the user is tabbing • Tab Stop--Allows the programmer to have a control skipped during tabbing. • Font--Allows the programmer to change the style of the captions and text.
MORE IMPORTANT PROPERTIES NUMERIC UP/DOWN BOXES • Value Property – (NUD) defines the current value displayed in the control • Minimum and Maximum Properties – (NUD) allows the programmer to define the upper and lower boundaries for the values in a NUD control. • Decimal Places Property – (NUD) allows the programmer to set up the number of decimal points allowed in the control. Default is 0.
COMMENT STATMENTS • COMMENT STATEMENTS – programmers often add comments within their code as a form of internal documentation. • A comment is text added within an event procedure that explains how the code works or why it is written. • Comments are not executed by the computer and are ignored by .NET • Comments are included for informational purposes and for other programmers. They are an excellent means for team’s of programmers to communicate with one another. • They also are a great way for you to leave notes to yourself or others. • Each comment line must begin with an apostrophe or the letters REM – which is short for “remark”.
NAMING CONTROLS • We learned four new controls this chapter. • Any of these objects that are receiving code must be renamed with one of the following prefixes: • TXT= Text box • BTN = Button • LBL = Label • NUD = Numeric Up/Down
EVENTS • Most windows applications are event-driven programs. • Events are messages sent to an object • Click event – default event for buttons. Code will execute when user Clicks on the button. • Event procedures, which are triggered by events, are groups of code statements • Code statements are instructions to the computer written at design time for the computer to execute at run time
Writing Code in the Code Window • Intellisense anticipates your needs during coding and displays prompts to assist you in coding • A syntax error is an error caused by code statements that violate one of the structure or syntax rules of the Visual Basic .NET language • Event procedures for controls start with the word Private Sub since the section is just for that one control. • The line that begins End Sub indicates the end of a particular event procedure.
Assignment Statements • controlname.propertyname=propertyvalue
Examples of Code from this chapter’s program • Code for the reset button
Chapter 3 Complete Building an Application in the Visual Basic .NET Environment