2MotivationWe'd like to be able to write programs that will run on WindowsWe'd like to use Rapid Application Development methodsWe’re interested in developing object-oriented, event-driven applications• MyAge, YourGrade, and ThisTestwere declared on the previous slides -must be declared first to use them
3Basic 10 sum = 0 20 FOR i = 1 to 100 30 sum = sum + i 40 NEXT i 50 avg = sum / 10060 PRINT "The average is " avg70 END
4RAD Rapid Application Development Easily develop interface prototypes Accelerates delivery of systemBetter user feedback and testingWYSISYG development
5Object-oriented Programming Think in real-world conceptsObjects haveProperties/attributes (nouns)Actions/events (verbs)Akin to a "record" on steroids! Groups data and procedural abstraction togetherProvides for encapsulation & information hiding
6Event-Driven Programming Basic and Pseudocode run from top to bottomMain program/algorithm in controlEvent-driven programs respond to eventsUsually graphical (forms, buttons, controls)Instructions are executed in response to eventsButton press, control change, form close, etc.
7Anatomy of a VB Program User clicks on the cmdBorder button FormControlsUser clicks on the cmdBorder buttonA Click() event is generatedThe cmdBorder_Click() method is executed
8Event-driven vs. Procedural algorithm CalcAges// create the 4 age variablesAge1, Age2, Age3, Age4 isoftype Num// prompt the user and then read in the// numbersprint("Please enter 4 ages")read(Age1, Age2, Age3, Age4)// I need a place to store the averageavg isoftype Num// calc the averageavg <- (Age1 + Age2 + Age3 + Age4) / 4// display it back to the userprint("The average age is ", avg)endalgorithm
9VB Program Development DesignCreate the User Interface (UI)Set form and control propertiesCode event handlersSave and test/debug your program often!Create executable fileCreate setup program (for deployment on other computers)
11Design vs. Run Time Design time When you’re building your program Some properties may not be setRun timeWhen you run your programEvents are generated from user (buttons, etc.)Opens up more properties of controls
12Versions Visual Basic has evolved and will continue to evolve We will be using VB.Net
13File Types VBP Visual Basic Project (meta file) VBW Visual Basic Workspace (settings of project)FRM Form (form, control, methods, & attributes)EXE Self-contained executable programSCC Visual SourceSafe file (for versioning/collaboration)others to be announced as needed
14MSDN Microsoft Developers Network Your lifeline Your best friend when programmingOn-line or on CD-RomMouse over “Libraries” and click “MSDN Libraries”Live it; Love it; Use it!
15Summary VB is based on Basic VB is a RAD language VB is an event-driven languageVB is an object-oriented languageVB comes in different versions and editionsImportant terms to know/understand:Form, control, method, event, attribute/propertyIDE, RAD, OOP