Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction 1. CIS 400 Programming for the Windows Environment 2.

Similar presentations


Presentation on theme: "Introduction 1. CIS 400 Programming for the Windows Environment 2."— Presentation transcript:

1 Introduction 1

2 CIS 400 Programming for the Windows Environment 2

3 VB History FORTRAN IBM 1957 BASIC Dartmouth 1964 BASICs Microsoft 1975 MS-DOS 1982 VB 1991 VB 1-6 VBA VB.NET 2001 VB 7-10 VBA 3

4 Visual Basic is one of four.NET applications (Visual C#, Visual C++, and Visual F#) included in Visual Studio. The main components of the.NET Framework are the Class Library (containing the pre-written code) and Common Language Runtime (which manages the execution of.NET programs)..NET FrameworkClass 4

5 Visual Basic is an object-oriented, event-driven language 5

6 Objects Button CheckBox Label and TextBox ListBox 6

7 Must begin with a letter. Must contain only letters, numbers, and the underscore character (_). Object Naming Punctuation characters and spaces are not allowed. Must be no longer than 40 characters 7

8 ObjectObject Naming Convention FormfrmfrmFileOpen Check boxchk chkReadOnly Command ButtoncmdcmdExit LabellbllblWind List boxlstlstState Text boxtxttxtLastName Vertical Scroll BarvsbvsbTemp Option (Radio) Button optoptAC Picture BoxpicpicJeep 8

9 An event is an action performed on an object. Event-driven subroutines are always in the form: object_Event The subroutine “handles” the event that happens to the object. Events 9

10 ObjectsEvents Click CheckChanged Leave MouseEnter 10

11 A property is an attribute associated with an object. Using the dot form: object.Property Properties can be assigned during design or run time. Properties 11

12 PropertiesObjects Text BackColor ReadOnly SelectionMode 12

13 A method is like a procedure, except that it is tied to an object (control or form), just like a property. In other words, a property is made up of data attached to the object, and a method is a procedure attached to the object. Unfortunately, methods also use the dot form: object.Method Methods 13

14 There are two ways to tell methods and properties apart. Methods are usually verbs (denoting action) like Hide or Select: frmMain.Hide() Properties are descriptive like ForeColor or Text: lblLetterGrade.Text="A" 14

15 Furthermore, a method is invoked by simply using the method statement. frmGetFile.Show() Whereas an object property is only part of a statement such as assignment. txtTemp.BackColor = Color.Red 15 For additional predefined colors, see: Color ListColor List and Color TableColor Table

16 For some methods, you must specify the class from which it is called and the syntax is different. Result = Math.Round(3.1415965,2) txtSubtotal.Text = Convert.ToString(subtotal) See pages 119 & 127 in the text for additional Math & Convert class methods. Class.Method(arg(s)) 16

17 int fff (... ) Local Items. Global Items (variables & constants) int main(). c/c++ execution begins here Preprocessor Directives (includes) 17

18 VISUALBASICVISUALBASIC FORM(s) Form Level Items Local Items Functions or Procedures MODULE(s) Project or Module Level Items Functions or Procedures Local Items Where does execution begin? 18

19 APPLICATION PROJECT FORM1.VB FORM2.VB. MODULE1.VB EDITOR APP.EXE COMPILER Syntax Errors DEBUGGER Run-time Errors (Exceptions) Logic Errors EDITOR 19

20 VB Project Files Solution (.sln) Project (.vbproj) Form (.vb) Plus several others Application (.exe) 20

21 Let’s begin by looking at a simple interest program written in c++ and Visual Basic. 21

22 22 #include int main(void) { float principle,rate,time,interest; cout "; cin >> principle; cout "; cin >> rate; cout "; cin >> time; interest = principle * rate * time; cout << "Interest is " << interest; cout << endl; return 0; } c++ Principle --> 1000 Rate --> 5 Time -->3 Interest is What is wrong with this?

23 23 VB

24 The full “Professional” version of Visual Studio 2010 has been installed on computers located in Chase 215. You can download a free copy of Visual Basic 2010 Express at: http://www.microsoft.com/visualstudio/ eng#downloads+d-2010-express http://www.microsoft.com/visualstudio/ eng#downloads+d-2010-express 24

25 VB Environment 25 Let’s design the interface and create the code for the simple interest program

26 We could: 26 Test for valid textbox contents: Non-empty Only numeric characters We could add: Additional instructions - % A Clear button

27 Read the Description Of Assigment-1 27


Download ppt "Introduction 1. CIS 400 Programming for the Windows Environment 2."

Similar presentations


Ads by Google