1 / 113

Course Plan

2-3 Weeks 1998. Course Plan. Consepts of Visual Basic Components Of IDE (Integrated Development Environment) First Visual Basic application Coding rules Properties, methods and events Controls Menües. Consepts Of Visual Basic. Type of Windows. Explorer windows (Windows 95)

Download Presentation

Course Plan

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. 2-3 Weeks 1998 Course Plan • Consepts of Visual Basic • Components Of IDE (Integrated Development Environment) • First Visual Basic application • Coding rules • Properties, methods and events • Controls • Menües

  2. Consepts Of Visual Basic Type of Windows • Explorer windows (Windows 95) • Document Window(Word) • Dialog Box(Pop Up Window) • Command buttons, icons, text boxes, menu bar

  3. Consepts Of Visual Basic Events and messages • Windows O.S assigns an unique handler to point each window • window handle hWnd • The system continually monitors each of these windows for signs of activity or events • Events can occur through • user actions(Such as mouse click or a key press) • or even as a result of another window’s action

  4. Consepts Of Visual Basic Events and Messages • Methods can be applied for an object • Result of another event • Each time an event occurs, it couses a message to be sent to O.S • O.S process the message and broadcasts it to the other windows • And each window takes the message and do the necessary process

  5. Consepts Of Visual Basic Windows Message Handler • Windows Message Handler operates this process • Windows Message Handler of Visual Basic do the same process as an interface • Many of these messages are handled automaticaly by Visual Basic • The other messages are left to the user application.

  6. Consepts Of Visual Basic Traditional and Event Driven Model • Traditional or Procedural programming • The application controls • Which portions of code execute • and in what sequence • Event driven programming • The code doesn’t follow a predetermined path • It executes different code sections in response to events

  7. Consepts Of Visual Basic Event Driven Model • Events can be triggered by the user’s actions • The sequence of these events determines the sequence in which the code executes • Which code section  Result of an event • In which sequence  Result of an event • Your code can also trigger events during execution

  8. Consepts Of Visual Basic Event Driven Model • Example • Changing the text in a text box cause the text box’s Change event to occure • If you assume that this event would only triggered by user interaction , you might see unexpected results • For this reason it is important to understand the event-driven model and keep it in mind when designing your application

  9. Consepts Of Visual Basic Development Phase • The traditional application Writing code, compiling, and testing • Visual Basic uses an interactive approach • Interprets your code as you enter it • Catching and highlighting most syntax or spelling errors on the fly. • Partially compiles the code as it is entered • If the compiler finds an error, it is high lited in your code. Fix the code and continue compiling

  10. Components Of IDE Integrated Development Environment • Title Bar • Menu Bar • Context Menus • Toolbars • Toolbox • Project Explorer window • Properties WIndow

  11. Components Of IDE Integrated Development Environment • Object Browser • Form Designer • Code Editor window • Form layout Window • Immediate, Locals, and Watch Windows

  12. Components Of IDE Title Bar • Displays the title and current process type of the project • Design • Run • Code

  13. Components Of IDE Menü Bar • Displays the commands you use to work with Visual Basic • Standard menües • File, Edit, View, Window, Help • Additional Visual Basic Menues • Project, Format, Debug, Run, Tools, Add-Ins

  14. Components Of IDE Context menu • Contains shortcuts to frequently performed actions. To open this menu , click the right mouse button on the object you’re using • Different menu for each object

  15. Components Of IDE Toolbar • Provide quick access to commonly used commands in programming environment • Standard, debug, edit, form editor tool bars • “Floating” or “dockable”

  16. Components Of IDE Tool Box • Provides a set of tools that you use at design time to place controls on a form • Standard toolbox(controls) • Your own custom layout controls • Add Tab from the context menu and adding controls to the resulting tab

  17. Components Of IDE Project explorer window • Lists the forms and modules in your current project • A project is the collection of files you use to build an application

  18. Components Of IDE Properties Window • Lists the property settings for the selected form or control • Alphabetic • Categorized • A Property is a characteristic of an object(size,caption,color, • name..)

  19. Components Of IDE Object Browser • Lists objects available for use in current project • see what methods and properties are avaible for those objects

  20. Components Of IDE Forms • Serves as a window • Design your application on this window. • Add controls, graphics, pictures etc. • Acts as a container for the various controls

  21. Components Of IDE Code Editor Window • Serves as an editor for entering application code • A separate code editor window is created for each form or code module in your application

  22. Components Of IDE Form Layout Window • Allows you to position the forms in your application using a small graphical representation of the screen

  23. Components Of IDE Immediate window • To see the values of each varibales which is prviously defined • Used for debugging purposes in running mode

  24. Components Of IDE Local window • Used in Break mode • list the values of local variables in the current active procedure

  25. Components Of IDE Watch window • Used in break mode

  26. First Visual Basic Application Steps of an Application • Creating the interface • Set properties • Write code

  27. Steps of an application Creating the interface • First step is to create the Forms that will be the basis for your application’s interface • Chose the necessary objects(controls) from tool box and put them into proper locations on the form • click the tool for the control • move the pointer on the form • Place the control into a proper location • Release the button

  28. Steps of an application Creating the interface • Resizing, moving and locking controls • Sizing handler(small rectentangular box) • Mouse, keyboard(shift+arrow key) • To move a control • Use the mouse to drag the control to a new location on the form • Use properties window to change the Top and Left properties

  29. Steps of an application Creating the interface • To Lock all control positions • This will lock all controls on the form in their current positions • From the Format menu chose Lock Controls

  30. Steps of an application Setting Properties • From View Menu • Click the Properties for a selected object • Object Box • Displays the Name of the object • Sort Tabs • Alphabetical • Categorized

  31. Steps of an application Settings properties • Properties List • Left Column displays all of the properties for the selected object. You can edit and view settings in the right column • Design Time Properties • Execution time properties(“Not available at design time”)

  32. Steps of an application Writing Code • Code editor window is used to write Visual Basic Code(See code Basics chapter 5) • To open code window • Double-click the form or control for which you chose to write code

  33. Steps of an application Writing Code

  34. Steps of an application Writin Code You can see more than one procedure on the same code window

  35. Steps of an application Writing Code Display Only one procedure(Tools(Options(Editor(Procedure view

  36. Steps of an application Objects and events

  37. Starting Visual Basic Sample Application • First Step Using Star Menu

  38. Starting Visual Basic Sample Application • Chose the type of project

  39. First Visual Basic Application Example

  40. First Visual Basic Application Sample application • Design phase(“Hello world!”) • Necessary objects(controls) • Label box(control) • Text box(control) • Command button(control) • Form

  41. Coding Rules • Rules for naming the objects • Constant and variables names • Skip this page

  42. Creating Event Procedure • An event procedure contains code that is executed when an event occurs • An event procedure for a control combines control’s actual name(Specified in Name property), an underscore( _ ), and the event name • Private Sub CmdAdd_Click()

  43. Creating Event Procedure • Format of changing the text property is Object.Property = Property value • Example • Text1.text = “Hello World !” • The event procedure will be • Private Sub Cmd_click() • TxtName.text = “Hello World !” • end sub

  44. Properties, Methods and Events • Properties can be thought of as an object’s attributes • A Methods is a function that acts on a particular object • Events as its responses with the user • An everyday object like a child’s Balloon also has properties

  45. Properties,methods, Events Properties • Visible Attributes • Color,diameter,Height • Other properties • State(inflated or not inflated) • Example • Balloon.Color • Balloon.State

  46. Properties,methods, Events Methods • A Methods is a function that acts on a particular object(Object.method) • Samples • Balloon.Inflate • Balloon.Deflate • Balloon.Rise

  47. Properties,methods, Events Events Events as its responses with the user • A Balloon’s Methods are • Balloon.inflate • Balloon.Deflate • Balloon.Rise 5

  48. Properties,methods, Events Methods • The syntax is similar to the property • Object.Method arguments(if it has) Example : Balloon.inflate Balloon.Rise 5 Some methods will have one or more arguments

  49. Event • The balloon might respond to an event as follows(in this case, the code describes the balloons behavior when a puncture event occurs) • Sub Balloon_Puncture() Balloon.Deflate Balloon.MakeNoise “Bang” Balloon.Inflated = True Balloon.Diameter = 1 End Sub

  50. Designing a Form(properties) • Form objects are the basic building blocks of Visual Basic application. • The actual windows which a user interacts when they run the application • Forms have their own properties, events, and methods with which you can control their appearance and behaviour

More Related