visual basic v6 introduction

3,121 views
2,905 views

Published on

1 Comment
6 Likes
Statistics
Notes
No Downloads
Views
Total views
3,121
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
330
Comments
1
Likes
6
Embeds 0
No embeds

No notes for slide

visual basic v6 introduction

  1. 1. Introduction to Visual Basic Visual B eginners A ll-Purpose S ymbolic I nstruction C ode
  2. 2. Visual Basic <ul><li>is a tool that allows you to develop Windows (Graphic User Interface - GUI ) applications . </li></ul><ul><li>is event-driven , meaning code remains idle until called upon to respond to some event. </li></ul>
  3. 3. Steps in Developing Application <ul><li>1. Draw the user interface </li></ul><ul><li>2. Assign properties to controls </li></ul><ul><li>3. Attach code to controls </li></ul>
  4. 4. Draw the User Interface <ul><li>Visual Basic operates in three modes. </li></ul><ul><li>Design mode - used to build application </li></ul><ul><li>Run mode - used to run the application </li></ul><ul><li>Break mode - application halted and debugger is available </li></ul>
  5. 5. Getting Started
  6. 6. 7 Windows <ul><li>Main Window </li></ul><ul><li>Form Window </li></ul><ul><li>Toolbox </li></ul><ul><li>Properties Window </li></ul><ul><li>Form Layout Window </li></ul><ul><li>Project Window </li></ul><ul><li>Code Editor Window </li></ul>
  7. 7. Main Window <ul><li>consists of the title bar, menu bar, and toolbar. </li></ul>
  8. 8. Form Window <ul><li>is central to developing Visual Basic applications. It is where you draw your application. </li></ul>
  9. 9. Toolbox <ul><li>is the selection menu for controls used in your application. </li></ul>
  10. 10. Properties Window <ul><li>is used to establish initial property values for objects. </li></ul>
  11. 11. Form Layout Window <ul><li>shows where (upon program execution) your form will be displayed relative to your monitor’s screen. </li></ul>
  12. 12. Project Window <ul><li>displays a list of all forms and modules making up your application. </li></ul>
  13. 13. Code Editor Window <ul><li>Contains the actual Basic coding. </li></ul>
  14. 14. Assign Properties to Controls <ul><li>Naming Convention of Controls </li></ul>Object Prefix Example Form frm frmHello Command Button cmd, btn cmdExit, btnStart Label lbl lblStart, lblEnd TextBox txt txtTime, txtName Menu mnu mnuExit, mnuSave Check box chk chkChoice
  15. 15. Attach Code to Controls <ul><li>Code in a Visual Basic application is divided into smaller blocks called procedures. </li></ul><ul><li>Event procedure syntax: </li></ul><ul><li>object name_event () </li></ul><ul><li>Ex. Command1_Click () </li></ul>
  16. 16. <ul><li>Private Sub object name_event () </li></ul><ul><li>End Sub </li></ul><ul><li>_______________________________________ </li></ul><ul><li>Private Sub Command1_Click () </li></ul><ul><li>End Sub </li></ul>
  17. 17. <ul><li>Private Sub Command1_Click () </li></ul><ul><li>object name.property = value </li></ul><ul><li>End Sub </li></ul><ul><li>_______________________________________ </li></ul><ul><li>Private Sub Command1_Click () </li></ul><ul><li>Text1.Text = &quot;Hello, world!&quot; </li></ul><ul><li>End Sub </li></ul>
  18. 18. Variables <ul><li>Rules used in naming variables: </li></ul><ul><li>No more than 40 characters. </li></ul><ul><li>They may include letters, numbers, and underscore (_). </li></ul><ul><li>The first character must be a letter. </li></ul><ul><li>You cannot use a reserved word. </li></ul>
  19. 19. Data Types
  20. 20. Variable Declaration <ul><li>1. Default (variant) </li></ul><ul><li>2. Implicit </li></ul><ul><li>Amount% = 300 </li></ul><ul><li>3. Explicit </li></ul><ul><li>four levels of scope </li></ul><ul><li>Procedure level </li></ul><ul><li>Procedure level, static </li></ul><ul><li>Form and module level </li></ul><ul><li>Global level </li></ul>
  21. 21. <ul><li>Procedure level </li></ul><ul><li>Dim Variable name as Data type </li></ul><ul><li>Ex. Dim Myint as integer </li></ul><ul><li>Procedure level, static </li></ul><ul><li>Static Variable name as Data type </li></ul><ul><li>Ex. Dim Myint as integer </li></ul>
  22. 22. <ul><li>Form and module level </li></ul><ul><li>Dim Variable name as Data type </li></ul><ul><li>Ex. Dim Myint as integer </li></ul><ul><li>Global level </li></ul><ul><li>Global Variable name as Data type </li></ul><ul><li>Ex. Dim Myint as integer </li></ul>
  23. 24. <ul><li>Procedure Routine1 has access to __, __, and __(…..) </li></ul><ul><li>Procedure Routine2 has access to __, __, and __(…..) </li></ul><ul><li>Procedure Routine3 has access to __, __, and __(…..) </li></ul>
  24. 25. <ul><li>Procedure Routine1 has access to X, Y, and A (loses value upon termination) </li></ul><ul><li>Procedure Routine2 has access to X, Y, and B (retains value) </li></ul><ul><li>Procedure Routine3 has access to X, Z, and C (loses value) </li></ul>

×