1 / 39

Applications Development

Applications Development. Using VB .Net Note: The prerequisites of this course are CMP218 or CMP219 or ITE204 and concurrent requisite of CMP252 or ITE252. Learning new languages. Computer Programming Languages. Can be classified into two basic types Object Oriented Programming

janus
Download Presentation

Applications Development

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. Applications Development Using VB .Net Note: The prerequisites of this course are CMP218 or CMP219 or ITE204 and concurrent requisite of CMP252 or ITE252

  2. Learning new languages

  3. Computer Programming Languages • Can be classified into two basic types • Object Oriented Programming • Procedural Programming • Each computer language classified under each “type” will follow specific guidelines. • knowing the specific guidelines within a language type will help in learning the different languages within each type.

  4. Computer Programming Languages (Continued) • Procedural Languages • Examples include • PASCAL • C • COBALD • Follow a top down design • Object Oriented Languages • Follow OOD (Object Orient Design) • Examples include • C++ • Java • VB .Net

  5. Object Oriented Languages Overview (Review questions) • Some questions that should be answered as a review. • What is OOP (Object Oriented Programming)? • What are Data Types (Primitive and Abstract)? • What is the String Data Types and its associated methods? • How do you convert numeric data from a String to a Primitive data type? • What is the difference between a class and an object? • What are attributes? • What are methods? • What is a constructor? • What is an Accessor? • What is a Mutator/Modifier? • What is inheritance? • What are loops? • What is Exception Handling and Why is it used? • What does public and private mean? • What are control structures (if and switch statements) • What are the following operators • Assignment? • Math? • Comparison/Logical? • Boolean?

  6. Classes in OOP • Are object descriptions • Contain both attributes and methods • Attributes are data types that describe the object • Can be both Primitive data types and other classes • Can be public or private • Methods are the actions that the object can do • Three types of methods • Constructor • Accessor • Mutator/Modifier • Every method contains a specific format • Every method contains an accessibility (public/private) • Every method contains a parameter lists (lists can be empty) • Every method contains a return type (can be void or nothing)

  7. Learning VB .net Comparing VB .net and Java

  8. Similarities of VB .net and Java • Both are object oriented • Both have public and private methods and attributes in a class • Both use exception handling • Both are event driven programming languages

  9. Noticeable differences between Java and VB .net • VB .net does not use semicolons • VB .net does not use curly braces • VB .net is not case sensitive • VB .net contains both Sub Procedures and Functions • VB .net primarily contains a visual interface for the programmer • VB .net runs on multiple platforms containing the VB .net environment • Every program in this class will start off with a form.

  10. Primitive Data Types in Java • int • float • double • boolean • byte • char • Long • Etc.

  11. Primitive (elementary) Data Types in VB .Net • Integer • Boolean • Decimal • Date • Double • Char • String • Etc.

  12. Converting Data Types in VB .net • Functions are used to convert text (String) data to numeric data • These functions include • Integer.Parse() • Double.Parse() • Decimal.Parse() • Etc. • These functions in VB .net behave much like the parsing methods in Java.

  13. Operators in VB .net • Math • + • - • * • / • Mod (Modulus or Remainder) • Assignment • =

  14. Operators in VB .net (continued) • Comparison • = (the same as assignment) • < • <= • > • >= • <> (Not equal) • Boolean (uses words not symbols) • And • Or • Not

  15. Variable declarations in VB .net vs. Java • In java the data type is placed before the label int num1; • In VB .net • All variable declaration requires the keyword Dim (stands for Dimension) • the label is placed in front of the data type • Option Explicit and Option Strict should be also turned on at the top of every class Dim num1 AsInteger

  16. Method Syntax in Java publicint Sum3 (int num1, int num2, int num3) { int answer; answer = num1 + num2 + num3; return answer; } • The return type is an integer • The number of parameters are 3 integers • The method is public

  17. Methods in VB .net • VB .net have Three specific types of methods for classes • Each method could still be • A Constructor of a class • An Accessor of a class (Called Property get) • A Mutator/Modifier of a class (Called Property set) • The two specific types are • Sub procedures (do not return a value) • Functions (return a value) • Properties (act as both a mutator and/or accessor

  18. Functions in VB .net • Functions can be both public and private • Functions return a value • The return type of the Function is always at the end of the method heading (different than Java) • Only one value may be returned from a Function • Functions contain a parameter list and function label/name

  19. Method (functions) Syntax in VB .net PublicFunction Sum3(num1 AsInteger, num2 AsInteger, num3 AsInteger) AsInteger Dim answer AsInteger answer = num1 + num2 + num3 return answer EndFunction • This Function is public • This Function contains 3 parameters of type Integer • This Function has a return type of an Integer

  20. VB .Net Specifics for developing windows applications

  21. Forms in VB .Net • Every form in VB .net is a class • There are usually two files that are associated with a form in vb (for this example form1 is our class name) • Form1.vb which is the file containing all methods that you write for your application • Form1.Designer.vb which holds the partial class and all the visual studio generated code

  22. Forms in VB .net (Continued) • Forms have default attributes (properties) and methods (sub procedures and functions) which are located in the partial class file. • Properties can be set with the properties Window/Pane in the .net development environment usually located on the right hand side.

  23. Forms in VB .net continued • Properties that can be set are • Text (Title in the title bar) • Background color • Name of the form (Like java should match the name of the file (class name) • Size • Icon (in the Title bar) • Etc. • Forms can also have attributes (properties) and methods (Functions and Sub Procedures) added to them

  24. Controls in VB .net • Items added to the form such as text boxes are called controls • Each control added to a form becomes an attribute of that form (or part of the form) • Each Control is an Object and have • Attributes (properties) • Methods (Functions and Sub-Procedures) • Controls can be found in the toolbox on the left hand side of the IDE.

  25. Controls in VB .net (Continued) • All properties can be set by using the properties window for each control. • Controls in VB .net include • Text Boxes • Buttons • Data Grids • Etc.

  26. Text Boxes • Used for entering text for a windows application • ALL Data entered in the text box is a String (like with JOptionPane) • All numeric data must be converted with the methods described earlier • The Text attribute will hold the Data entered into the text box

  27. Events and Windows Applications • Windows is an event driven operating system (Flow of control is driven by events that occur) • Events are messages that are passed to applications and objects when something in the program occurs • Events can be a mouse click, positions of the Mouse etc.

  28. Buttons and Event handling • By double clicking on the Button control on the form, sub program headings for handling the click event are inserted. • All code that is entered into the event handler will only execute in the program when the button is clicked. • Other event handlers for the button control include • MouseHover • MouseLeave • Etc. • Can place code in the other event handlers by selecting the event in the upper left corner of the code view of the current Form.

  29. Forms and event handling • another event that is handled in programs written in class is the Form load event. • The form load event handler fires every time the form loads. • All initialization can be done inside of the form load event handler. • To add a form load event handler, double click anywhere on the form and write the code needed to handle this event.

  30. Control Structures in VB .net Similarities and differences between Java and VB .Net

  31. If statements in Java if (num1 == 4) { System.out.println(“num1 is 4”); }else { System.out.println(“num1 isn’t 4”); }

  32. If Statements in VB .net If num1 = 4 Then MessageBox.Show(“num1 is 4”) Else MessageBox.Show(“num1 isn’t 4”) EndIf

  33. VB .net If statements (continued) • Again no semicolons • No curly braces • End If ends the if statement • Single equal sign is used for comparisons and assignments

  34. Select Case Statements • Are a lot like switch statements in Java • Unlike Java, Select Case statements will accept the use of any data type • Can be used in place of nested if statements Dim OP AsString = "+" SelectCase OP Case "-" Answer = Num1 - Num2 Case "+" Answer = Num1 + Num2 EndSelect

  35. Loops in VB • There are many different types of loops in VB • These Loops include • For Loops (counting) • While Loops • Do-While Loops • For each Loops • For Loops are generally used for indexing lists • For each Loops are used to traverse lists of data without the use of an index

  36. For Loop in VB Dim Index AsInteger ForIndex = 1 To 10 …… Some Code in Here …… Next • The Code Block is defined between the For statement line and the Next keyword • From this example all code within the code block will be executed ten times. • Unlike Java, VB does not need to have the statement Index++ to increment the index.

  37. For Each Loop in VB DimMyList() AsInteger = {1, 2, 4, 3} ForEach Item AsIntegerInMyList …….Some Code in Here……… Next • For Each will traverse the list without the use of an index variable • Item will hold the value of each spot in the array at each iteration of the Loop • Used widely in list manipulations

  38. While Loop in VB Dim Counter AsInteger = 0 WhileCounter <= 10 Counter += 10 EndWhile • Will repeat the code in the code block until Counter reaches the value of 10 • The code Block is defined between the While and EndWhile Keywords.

  39. Do While Loop in VB Dim Counter AsInteger = 0 Do Counter +=10 LoopWhile Counter <= 10 • The Code Block with this type of loop is located between The Do keyword and Loop While Keyword • With this example, the code block will execute 11 times • Behaves the same way as the do-while loops in Java.

More Related