Introduction To VB

2y ago
28 Views
3 Downloads
247.76 KB
10 Pages
Last View : 29d ago
Last Download : 3m ago
Upload by : Lilly Andre
Transcription

OutlineIntroductiontoVisual Basic .NETCS 1408 Intro to CSwith VB.NETIntroduction to VB.NET Elements of a Visual Basic ApplicationGetting started in Visual BasicAdding an event procedureAdding controlsAdding additional event proceduresFocus on program design and implementation:Creating a main menu Knowing about: The help facility Common programming errors and problems1CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET2Elements of a VB ApplicationThe Visual ElementThe Visual Basic language is an object-orientedlanguage that consists of two fundamental parts : The visual part of an application consists of the graphicaluser interface (GUI) of the application. A GUI is constructed by placing a set of visual objects on aform. The standard object Toolbox contains the objects that canbe used in constructing a GUI. Each object contains two basic characteristics:– The Visual part -- consists of a set of objects.– The Language (code) part -- consists of a high-levelprocedural programming language.– To create an application -- which is a VB application orprogram that can be run under the Windows operatingsystem both elements of the language, objects and code,must be used together.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET3– Properties -- define particular characteristics of the object and– Methods -- are the predefined procedures that are supplied with theobject for performing specific tasks. Each object from the Toolbox recognizes certain actions,which are referred to as events.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET41

The Language ElementGetting Started in VB Visual Basic is a high-level programminglanguage that supports all of the proceduralprogramming features found in othermodern languages. In GUIs and event-driven applications, thecode that is executed depends on whatevents occur, which in turn depends onwhat the user does. Visual Studio is the integrated developmentenvironment (IDE) that is used to create,test, and debug projects. Launching Visual Basic .NET displays theStart Page.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET5Start Visual Studio .NETfrom the Windows DesktopCS 1408 Intro to CSwith VB.NETIntroduction to VB.NET6Visual Basic .NET Start PageStart page allows theprogrammer to open recentprojects, open any previouslysaved project, and create a newproject.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET7CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET82

New Project Dialog WindowVB .NET IDE Windows WorkspaceClicking the New project button on the Start Page to open the New ProjectDialog box CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET9VB .NET WorkspaceWhen a new project iscreated, the GUI designercomponent of the IDE isdisplayed.The IDE also has twoother components: a codeeditor and a debugger.The IDE offers all of thecapabilities of aWindows-basedapplication, such as theability to resize and closeany of the child windows,as well as the overallparent window.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET10VB .NET Applications The steps that are required for creating a VisualBasic application are:1. Create the graphical user interface (GUI).2. Set the properties of each object on the interface.3. Write the code or add events.4. Debug -- test the application. The first step, creating the GUI, consists of addingobjects from the Toolbox to the design form.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET11CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET123

ToolboxSolution Explorer Window The Toolbox windowcontains a set of controlsthat can be placed on aForm window to producea graphical user interface(GUI – “goo-ey”). The toolbox can beopened by choosing thecommand Toolbox in theView menu.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET Solution ExplorerWindow provides aneasy access todifferent applicationfiles including filescontains forms andcodes.13CS 1408 Intro to CSwith VB.NET CS 1408 Intro to CSwith VB.NETOnce objects have been added tothe form, the next step is setting theproperties of the objects.The properties of objects are setthrough the Properties window orcode (inside the program).Two important properties ofobjects are the Name property andthe Text property.The Name property allows theprogrammer to assign a descriptivename to an object, rather than usingthe default name provided byVisual Basic for that object.The value of the Text property ofan object is displayed to the userwhen the application is running.Introduction to VB.NET1514Add Event ProcedureProperties Window -- Set Properties Introduction to VB.NET An event procedure is a procedure or event handler executed when that event occurs.The first line of a procedure is a header line.A header line begins with the optional keyword Private and must contain the keyword Sub, the nameof the procedure, and a set of parentheses.The last line of each procedure consists of the keywords End Sub.All statements from the header line to and including the End Sub statement are collectively referredto as the procedure’s body.The first and last lines of a procedure, consisting of the header line and the End Sub statement, arereferred to as the procedure’s template.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET164

Test or Run ApplicationSaving and Recalling a Project You can run your program at any time duringprogram development: To save an application– Click the File menu and then click Save All or– Click the SaveAll icon in the Standard Toolbar– Select the Debug Menu and click Start or– Press the F5 function key or– Use the hot key sequence Alt D, then press the S key To retrieve a project:– Select Open Solution from the File menu Design time: when an application is beingdeveloped Run time: when a program is executingCS 1408 Intro to CSwith VB.NETIntroduction to VB.NET17Example – Step 1: Adding ControlsCS 1408 Intro to CSwith VB.NETIntroduction to VB.NET19CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET18Example -- Step 2: AddingPropertiesCS 1408 Intro to CSwith VB.NETIntroduction to VB.NET205

Running an ApplicationExample -- Step 3: Adding EventsA project being developedcan be executed by usingany one of the followingthree methods:– Select the Debug Menu andclick Start.– Press the F5 function key.– Use the hot key sequenceAlt D, then press the S key.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET21 Introduction to VB.NETA procedure that is executed when an event occurs is referred to as an event procedure or eventhandler.The first line of a procedure is always a header line. A header line begins with the optional keywordPrivate and must contain the keyword Sub, the name of the procedure, and a set of parentheses.The last line of each procedure consists of the keywords End Sub.All statements from the header line to and including the End Sub statement are collectively referredto as the procedure’s body.The first and last lines of a procedure, consisting of the header line and the End Sub statement, arereferred to as the procedure’s template. The MessageBox.Show method can be used in aprocedure to display a message to the user through amessage box. The message box also contains a title and an icon. The general forms of the MessageBox.Show eBox.Show(text,defaultbutton)CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET22The MessageBox.Show MethodAdding an Event Procedure CS 1408 Intro to CSwith VB.NET23CS 1408 Intro to CSwith VB.NETcaption)caption, buttons)caption, buttons, icon)caption, buttons, icon,Introduction to VB.NET246

Message Box with CaptionMessage Box with ButtonsMessageBox.Show("Warning Message!!!!", "Error eBox.Show("Warning Message!!!!", "Error Warning Message!!!!", "Error w("Warning Message!!!!")Other values–––MessageBox.Show("Warning Message!!!!", "Error Message")CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET25Message Box with ncelMessageBoxButtons.YesNoCancelCS 1408 Intro to CSwith VB.NETThe exclamation (Exclamation and Warning) icon should beused when the user must make a decision before the program cancontinue.MessageBox.Show("Warning Message!!!!", "ErrorMessage", ion)MessageBox.Show("Warning Message!!!!", "ErrorMessage", The stop (Error, Hand and Stop) icon should be used with an OK buttonwhen an error or problem occurs and needs to be resolved.MessageBox.Show("Warning Message!!!!", "ErrorMessage", ox.Show("Warning Message!!!!", "ErrorMessage", x.Show("Warning Message!!!!", "ErrorMessage", uction to VB.NET26Message Box with IconsThe information (Asterisk and Information) icon should be used whena message displayed with an OK button.MessageBox.Show("Warning Message!!!!", "ErrorMessage", geBox.Show("Warning Message!!!!", "ErrorMessage", MessageBoxButtons.OK,MessageBoxIcon.Information)CS 1408 Intro to CSwith VB.NETIntroduction to VB.NETThe question (Question) icon should be used when a question needsto be answered.MessageBox.Show("Warning Message!!!!", "ErrorMessage", CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET287

Message Box with Default ButtonMessage Box with Default Button MessageBox.Show("Warning ning ning ssageBoxDefaultButton.Button3)CS 1408 Intro to CSwith VB.NET"Error Message",MessageBoxIcon.Exclamation, "Error Message",MessageBoxIcon.Exclamation, –––––––"Error Message",MessageBoxIcon.Exclamation,Introduction to VB.NETMessageBoxDefaultButton.Button1- - specifies the leftmost button and is thedefault.MessageBoxDefaultButton.Button2- - specifies the second button from theleft.MessageBoxDefaultButton.Button3- - specifies the third button from the left.When the button is clicked, the value returned is one of the following:29Adding Result.RetryDialogResult.YesCS 1408 Intro to CSwith VB.NETIntroduction to VB.NET30Setting the Initial Object Properties Objects placed on a formare called controls. These objects can beadded from the Toolbox. The simplest method ofadding a control to a formis to double-click thedesired object in theToolbox.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET31Once controls have beenadded to a form, wecan use the Propertieswindow to change oneor more of theproperties of thecontrols.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET328

Looking at the Focus and TabSequence Adding Additional Event ProceduresWhen an application is run and a user islooking at the form, only one of the form’scontrols will have input focus, or focus.Only objects which are capable of respondingto user input through either the keyboard ormouse can receive focus.In order to receive the focus, a control musthave its Enabled, Visible, and TabStopproperties set to True.The sequence in which the focus shifts fromcontrol to control as the tab key is pressed bythe user is called the tab sequence.The programmer can alter the default taborder – which is obtained from the sequencein which controls are placed on the form – bymodifying an object’s TabIndex value.CS 1408 Intro to CSwith VB.NETIntroduction to VB.NET Once we have added objects to a form and set theproperties of these controls, the next step increating a Visual Basic application is to supplythese objects with event code. Each object can have many events associated withit. To enter the event code for an object, we candouble-click the object to open its Code window.33CS 1408 Intro to CSwith VB.NETCommentsIntroduction to VB.NETStatement Comments are explanatory remarks madewithin a program. Comments are written using an apostropheor the keyword Rem. Comments are ignored by Visual Basic anddo not impact the execution of a program. All statements belong to one of two categories ofstatements:CS 1408 Intro to CSwith VB.NETCS 1408 Intro to CSwith VB.NETIntroduction to VB.NET3435– executable statements– nonexecutable statements. An executable statement causes some specificaction to be performed by the compiler orinterpreter. A nonexecutable statement describes some featureof either the program or its data but does not causethe computer to perform any action.Introduction to VB.NET369

Help FacilityHelp Facility Visual Basic’s Help Facility can be accessed byselecting either the Contents, Search, or Indexoptions from the Help menu The Contents tab displays a Table of Contents forthe documentation The Index tab provides both a general index oftopics and a text box for user entry of a specifictopic The Search tab provides a means of entering asearch word or phrase Dynamic HelpCS 1408 Intro to CSwith VB.NETCS 1408 Intro to CSwith VB.NETIntroduction to VB.NET37– The Dynamic Help window displays a list of helptopics that changes as you perform operations– To open the Dynamic Help window, click Help on themenu bar and then click Dynamic Help Context-sensitive Help– Context-sensitive Help immediately displays a relevantarticle for a topic– To use this facility, select an object and press F1Introduction to VB.NET3810

with VB.NET Introduction to VB.NET 6 Getting Started in VB Visual Studio is the integrated development environment (IDE) that is used to create, test, and debug projects. Launching Visual Basic .NET displays the Start Page. CS 1408 Intro to CS with VB.NET Introduction to VB.NET 7 Start Visual Studio .NET from the Windows Desktop

Related Documents:

work/products (Beading, Candles, Carving, Food Products, Soap, Weaving, etc.) ⃝I understand that if my work contains Indigenous visual representation that it is a reflection of the Indigenous culture of my native region. ⃝To the best of my knowledge, my work/products fall within Craft Council standards and expectations with respect to

Advertise Monetize CPS 소개서 TNK CPS Introduction 매체소개서 Monetize Introduction About Us TNK Factory Introduction 회사소개서 DSP 소개서 TNK DSP Introduction 퍼포먼스 소개서 Performance Introduction 코드뱅크 소개서 Codebank Introduction TNK Factory는 안전하고 빠르며 쉬운 플랫폼입니다.

An Introduction to Modal Logic 2009 Formosan Summer School on Logic, Language, and Computation 29 June-10 July, 2009 ; 9 9 B . : The Agenda Introduction Basic Modal Logic Normal Systems of Modal Logic Meta-theorems of Normal Systems Variants of Modal Logic Conclusion ; 9 9 B . ; Introduction Let me tell you the story ; 9 9 B . Introduction Historical overview .

Partie 1 : Introduction et fonctions 1-1-1 Section 1 : Introduction Surveillance STEPS de l'OMS Section 1: Introduction Présentation générale Introduction Cette section constitue une introduction au Manuel de l'OMS pour la surveillance STEPS. Objectif L'objectif du Manuel est de proposer des lignes directrices et de fournir des

1.1 Introduction 1.2 Context 1.3 Purpose and scope 1.4 Language and terms Chapter 1: Introduction to essential health services 1.1 Introduction 1.2 Purpose & scope 1.3 Language and terms Chapter 1: Introduction to essential justice and policing services 1.1 Introduction 1.2 Purpose & scope 1.3 Language and terms Chapter

(Text from Modern Biology, Holt, Rinehart, and Winston) 1 Chapter Eighteen (Introduction to Ecology)Chapter Eighteen (Introduction to Ecology) SECTION ONE: INTRODUCTION TO ECOLOGYSECTION ONE: INTRODUCTION TO ECOLOGYONE: INTRODUCTION TO ECOLOGY EcologyEcologyEcology is the study

General introduction to Unreal Engine - 3 days 100.1 Introduction to Unreal Engine (self-paced learning video) 1. 100.2 Quick Start: Your First Project in Unreal Engine 2. 101.1 Materials - Introduction 3. 103.1 Lighting - Introduction 4. 102.1 Blueprint - Introduction 5. 102.2 Blueprint - Introduction to UMG and Creating Simple User .

CSC266 Introduction to Parallel Computing using GPUs Introduction to Accelerators Sreepathi Pai October 11, 2017 URCS. Outline Introduction to Accelerators GPU Architectures . An Evaluation of Throughput Computing on CPU and GPU" by V.W.Lee et al. for more examples and a comparison of CPU and GPU. Outline Introduction to Accelerators GPU .