1 / 16

Introduction to Visual Basic .NET

Introduction to Visual Basic .NET. Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI. Topics. Introduction to VB .Net Data types and Operators in VB .Net Conditions (If Else, Select Case) Loops (Do While, Do Until, For) Classes, Objects Sub routines and Functions

Download Presentation

Introduction to Visual Basic .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Visual Basic .NET Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI

  2. Topics • Introduction to VB .Net • Data types and Operators in VB .Net • Conditions (If Else, Select Case) • Loops (Do While, Do Until, For) • Classes, Objects • Sub routines and Functions • Windows Application

  3. Introduction • VB .Net is developed by Microsoft • It is Visual Basic for .Net Platform • Ancestor of VB .Net is BASIC • In 1991, Microsoft added visual components to BASIC and created Visual Basic • After the development of .Net, VB was added with more set of controls and components and thus evolved a new language VB .Net

  4. Features of VB .Net • Object Oriented Language • We can drag controls from the tool bar and drop them on the form and write code for the controls • Runs on the CLR (Common Language Runtime)

  5. Data types and Operators in VB .Net • Data types • Integer, string, single, double, boolean, char • Declaring a variable • DIM i as Integer • DIM name as string • Operators • Arithmetic (+,-,*,/,Mod) • Logical (Or, And, Not) • Relational (=,<>,<,<=,>,>=)

  6. If Else If (Condition) Then Statements executed if condition is true Else Statements executed if condition is false EndIf We can also have Else If block in If Else statements

  7. Select Case Select Case var Case 1 stmt1 // executed if var = 1 Case 2 stmt2 // executed if var = 2 Case Else stmt3 // executed if var is other than 1 and 2 End Select

  8. For Loop For <<var>> = start To end Step <<val>> Statements Next Eg For I = 1 To 10 Step 2 Console.WriteLine(I) Next Here the values printed will be 1,3,5,7,9

  9. Do While Loop • Do While(a<>0) Console.Writeline(a) a = a – 1 Loop 2. Do Console.Writeline(a) a = a – 1 Loop While(a<>0)

  10. Class • Software structure that is important in Object Oriented Programming • Has data members and methods • Blue print or proto type for an object • Contains the common properties and methods of an object • Few examples are Car, Person, Animal

  11. Object • Instance of a class • Gives Life to a class • Ahmad is an object belonging to the class Person • Ford is an object belonging to the class Car • Jimmy is an object belonging to the class Animal

  12. Classes vs Modules • Classes • classes can be instantiated as objects • Object data exists separately for each instantiated object. • classes can implement interfaces. • Members defined within a class are scoped within a specific instance of the class and exist only for the lifetime of the object. • To access class members from outside a class, you must use fully qualified names in the format of Object.Member. • Modules • Modules cannot be instantiated as objects, because there is only one copy of a standard module's data, when one part of your program changes a public variable in a standard module, • Members declared within a module are publicly accessible by default. • It can be accessed by any code that can access the module. • This means that variables in a standard module are effectively global variables because they are visible from anywhere in your project, and they exist for the life of the program.

  13. Subroutines and Functions • Subroutines • Does not return any value • Can have zero or more parameters • Functions • Always Returns some value • Can have zero or more parameters

  14. Windows Application • File -> New -> Project • Select Language as VB .Net • Select .Net template as Windows Application • Give the path where the application need to be saved • A application opens up with a Form

  15. Forms and other controls • Form is a container for other controls • We can place the following in a form • Label • Text Box • Check Box • Radio Button • Button • Date Picker • And more…

  16. Properties and Events • Every Control has a set of properties, methods and events associated with it • Eg Form • Properties • Name (program will use this name to refer) • Text (title of the form) • Methods • Show • Hide • Close • Events • Load • UnLoad

More Related