Visual Basic - Chapter 2Mohammad Shokoohi* Adopted from An Introduction to Programming Using Visual Basic 2010, Schneider1
Chapter 2 –Visual Basic,Controls, and Events2.1 An Introduction to Visual Basic2.2 Visual Basic Controls2.3 Visual Basic Events2
2.1 An Introduction toVisual Basic 2010 Why Windows and Why Visual Basic How You Develop a Visual BasicApplication The Different Versions of Visual Basic3
Visual Basic 2010 Language used to create Windowsapplications. Provides a Graphical User Interface orGUI. The sequence of instructions executed inthe program is controlled by events.4
Sample Input Screen5
How to Develop a VisualBasic Application Design the Interface for the user. Determine which events the controls onthe window should recognize. Write the event procedures for thoseevents.6
Different Versions of VisualBasic Version 1.0 – 1991Version 2.0 – 1992Version 3.0 – 1993Version 4.0 – 1995Version 5.0 – 1997Version 6.0 – 1998Visual Basic.NET – 2002 (NOTBACKWARD COMPATIBLE WITHEARLIER VERSIONS) Visual Basic 2005 – November 2005 Visual Basic 2008 – November 2007 Visual Basic 2010 – April 20107
2.2 Visual Basic Controls Starting a New Visual Basic ProgramText Box ControlButton ControlLabel ControlList Box ControlName PropertyFonts / Auto HidePositioning and Aligning Controls8
Visual Basic Start Page9
Start a New Project10
New Project Dialog Boxselectclick on OK button11
Initial Visual Basic Screen12
Toolbox13
4 Ways to Place a Control from theToolbox onto the Form Designer Double-clickDrag and DropClick, Point, and ClickClick, Point, and Drag14
Four Controls at Design Timetext boxTo select a control, click on it. Sizing handleswill appear when a control is selected.15
Text Box Control Used for input and output When used for output, ReadOnlyproperty is set to TrueTasks buttonsizing handles16
Properties WindowPress F4 todisplay thePropertieswindow forthe selectedcontrol.categorized viewalphabetical view17
Properties ionpanesettings18
Some Often Used Properties adOnly19
Setting Properties Click on property name in left column. Enter its setting into right column bytyping or selecting from optionsdisplayed via a button or ellipses.20
Setting the ForeColor Property1. Click on ForeColor.2. Click on button atright of settings box.3. Click on Custom tabto obtain displayshown.4. Click on a color.21
Font Property1. Click on Fontin left column.2. Click onellipsis at rightof settings boxto obtaindisplay shown.3. Makeselections.22
Button Control The caption on the button should indicatethe effect of clicking on the button.Textproperty23
Add an Access Key24
Label Control Used to identify the contents of a text box. Text property specifies caption. By default, label automatically resizes toaccommodate caption on one line. When the AutoSize property is set to False,label can be resized manually. AutoSize isused primarily to obtain a multi-rowed label.25
List Box Control Initially used to display several pieces ofoutput. In Chapter 4 used to select from a list.26
The Name Property Used by the programmer to refer to a controlin code Setting for Name property near top ofProperties window Use appropriate 3-character naming prefix Use descriptive names27
Control Name PrefixesControlbuttonlabeltext boxlist tAddresslstOutput28
Renaming the Form Initial name is Form1 The Solution Explorer window lists a filenamed Form1.vb. To rename the form, change the name ofthis file to newName.vb newName should begin with prefix frm.29
Fonts Proportional width fonts, such asMicrosoft Sans Serif, use less space for"I" than for "W" Fixed-width fonts take up the sameamount of space for each character –like Courier New Fixed-width fonts are used for tables.30
Auto Hide Hides Toolbox when not in use Vertical push pin icon indicates auto hideis disabled. Click the push pin to make it horizontaland enable auto hide.push pin31
Positioning Controlsproximityline32
Aligning Bottoms of Controlssnap line33
Aligning Middles of Controlssnap line34
Tab OrderThe tab indicesdetermine the order inwhich controls receivethe focus during tabbing.The control whoseTabIndex property is setto 0 has the focus whenthe program begins.35
2.3 Visual Basic Events An Event Procedure Walkthrough Properties and Event Procedures of theForm The Header of an Event Procedure36
Event An event is an action, such as the userclicking on a button Usually, nothing happens in a VisualBasic program until the user doessomething and raises an event. What happens is determined bystatements inside the event procedure.37
Sample Statements txtBox.ForeColor Color.Red txtBox.Visible True txtBox.Text "Hello World"General Form:controlName.property setting38
Sample FormtxtFirsttxtSecondbtnRed39
Focus When you click on a text box, a cursorappears in the text box, and you can typeinto the text box. Such a text box is said to have the focus. If you click on another text box, the first textbox loses the focus and the second text boxreceives the focus.40
Examples of Events btnShow.Click txtBox.TextChanged txtBox.LeaveGeneral Form:controlName.event41
The Three Steps in Creating aVisual Basic Program1. Create the interface; that is, generate,position, and size the objects.2. Set properties; that is, configure theappearance of the objects.3. Write the code that executes whenevents occur.42
Code EditorCode EditortabFormDesigner tab43
Display Events for a Control Select the control Click on the Eventsbutton ( ) in theProperties windowevents button44
Structure of an EventProcedurePrivate Sub objectName event(.)headerHandles objectName.eventstatementsEnd Sub(.) is filled automatically with (ByVal senderAs System.Object, ByVal e AsSystem.EventArgs)45
Create an Outline for an EventProcedure Double-click on a controlor Select a control, click on the Events buttonin the Properties window, and double-clickon an event(We nearly always use the first method.)46
Sample FormtxtFirsttxtSecondbtnRedDouble-click on txtFirst to create the outlinefor the Code Editor47
Code for WalkthroughPublic Class frmDemoPrivate Sub txtFirst TextChanged(.)Handles txtFirst.TextChangedtxtFirst.ForeColor Color.BlueEnd SubEnd Class48
IntelliSenseAutomatically pops up to help the programmer.txtFirst.49
Code Editorclick tab to return to Form Designer50
Sample FormtxtFirsttxtSecondbtnRedDouble-click on btnRed to return to Code Editorand add the outline of an event procedure51
Code for WalkthroughPublic Class frmDemoPrivate Sub txtFirst TextChanged(.)Handles txtFirst.TextChangedtxtFirst.ForeColor Color.BlueEnd SubPrivate Sub btnRed Click(.)Handles btnRed.ClicktxtFirst.ForeColor Color.RedEnd SubEnd Class52
Event Procedure txtFirst.Leave Select txtFirst on the form Click on the Events button in theProperties window Double-click on Leave53
Code for WalkthroughPrivate Sub txtFirst Leave(.)Handles txtFirst.LeavetxtFirst.ForeColor Color.BlackEnd SubPrivate Sub txtFirst TextChanged(.)Handles txtFirst.TextChangedtxtFirst.ForeColor Color.BlueEnd SubPrivate Sub btnRed Click(.) Handles btnRed.ClicktxtFirst.ForeColor Color.RedEnd Sub54
Header of Event ProcedurePrivate Sub btnRed Click( ) Handles btnRed.ClickName, canbe changed.Identifies eventPrivate Sub Button Press( ) Handles btnRed.Click55
Handling Multiple EventsAn event procedure can be invoked by twoevents.Private Sub Happening(.)Handles btnRed.Click,txtSecond.LeavetxtFirst.ForeColor Color.RedEnd Sub56
Altering Properties of the Form The following won't work:frmDemo.Text "Demonstration" The form is referred to by the keyword Me.Me.Text "Demonstration"57
Open and Run an ExistingProgram Click on Open Project in the File menu.Navigate to the program’s folder.Double-click on the program’s folder to open it.Double-click on the file with extension sln.In the Solution Explorer double-click on the filewith extension vb. (The Form Designer willappear.) Press F5 to run the program.58
Visual Basic - Chapter 2 Mohammad Shokoohi * Adopted from An Introduction to Programming Using Visual Basic 2010, Schneider. 2 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events. 3 2.1 An Introduction to
Part One: Heir of Ash Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Chapter 25 Chapter 26 Chapter 27 Chapter 28 Chapter 29 Chapter 30 .
TO KILL A MOCKINGBIRD. Contents Dedication Epigraph Part One Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Part Two Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18. Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Chapter 25 Chapter 26
Visual Basic 6.0 versus Other Versions of Visual Basic The original Visual Basic for DOS and Visual Basic F or Windows were introduced in 1991. Visual Basic 3.0 (a vast improvement over previous versions) was released in 1993. Visual Basic 4.0 released in late 1995 (added 32 bit application support).
Visual Basic is a third-generation event-driven programming language first released by Microsoft in 1991. The versions of visual basic in shown below: The final version of the classic Visual Basic was Visual Basic 6. Visual Basic 6 is a user-friendly programming language designed for beginners. In 2002, Microsoft released Visual Basic.NET (VB .
DEDICATION PART ONE Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 PART TWO Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 .
What Visual Basic is not H Visual Basic is not, a powerful programming language that enables you to do anything you want. H Visual Basic is not, elegant or fast. H Visual Basic is not, a replacement for C. H Visual Basic is not, anything like any other programming language you have ever used.
Visual Basic 8.0 o Visual Basic 2005, nato nel 2005, è stato implementato sul .NET Framework 2.0. Non si usa più la keyword .NET nel nome, in quanto da questo momento sarà sottointeso che Visual Basic è basato sul .NET Framework. Visual Basic 9.0 o Visual Basic 2008, nato nel 2008, è stato implementato sul .NET Framework 3.5.
Anatomi tulang pada tangan, terdiri atas tulang lengan atas (humerus), pergelangan tangan (carpal), telapak tangan (metacarpal), dan jari-jari. Setiap lengan melekat pada tulang belikat (scapula), yaitu tulang segitiga besar di sudut tulang bagian atas setiap sisi tulang rusuk. Kerangka tubuh terdiri atas berbagai jenis tulang yang memiliki fungsi dan bentuk yang berbeda untuk menjalankan .