1 / 28

Introduction to Visual Basic

Introduction to Visual Basic. What it is, and a simple program. Mike Thelwall University of Wolverhampton, UK. Origins through BASIC. B eginners A ll-purpose S ymbolic I nstruction C ode A simple programming language Developed mid 1960’s

claire
Download Presentation

Introduction to Visual Basic

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. Introduction to Visual Basic What it is, and a simple program Mike Thelwall University of Wolverhampton, UK

  2. Origins through BASIC • BeginnersAll-purposeSymbolicInstructionCode • A simple programming language • Developed mid 1960’s • Simplicity of BASIC made it a natural choice as a programming language • Most machines have own version of BASIC

  3. Windows Programming • Visual Basic developed for Windows by Microsoft from BASIC • Interface designer • Simple coding language • Quick to produce programs • Versions of it are now also in Excel, Access, Word, PowerPoint and many other software

  4. What is it good for? • Lots of things! • But particularly… automating repetitive tasks that are governed by strict rules • It is a relatively easy to learn language • Good for those who are not ‘real’ programmers

  5. Designing a Program – Draw it first

  6. VB Environment: Menu Bar • The Menu Bar consists of 3 elements the • Title Bar, which holds the name of application, default if Microsoft Visual Basic [design] • Menu Bar, this is the link to Visual Basics menu facilities, each menu option drops down into sub-menus • Toolbar, contains icons which give access to the more commonly used commands (which are also available through the menu bar) Title bar Menu Bar Toolbar

  7. VB Environment: Control Toolbox Picture Text Box Command Button Option/Radio Button List Box Vertical Scroll Bar Drive List Box File List Box Line Data Control Grid Pointer Label Group Frame Check Box Combo Box Horizontal Scroll Bar Timer Directory List Box Shape Image Common Dialog OLE

  8. VB Environment: Properties Window

  9. Events and Visual Basic • Start by drawing the screen • Then add program code for Button Clicks Trigger Event Code Executed

  10. Visual Basic Environment

  11. Programming Application Example • You have a large text file containing 100,000 lines, each one of which is a reference from a journal article, with details of the author • You want to count how many of these references are to SUNY Albany faculty • Visual Basic can make this task possible

  12. Designing the Program • Open the text file • Read in the first line of text • Check if the line contains “SUNY Albany” • Keep a running total of how many matches there are • Read in the next line and repeat • Display the total count when finished

  13. What it looks like

  14. The code

  15. The data nobody, no journal someone not from Albany, journal of nothing someone else not from Albany, journal of nothing john smith, SUNY Albany, Topological properties of Spheres Rong Tang, SUNY Albany, Some very hard information science nobody, no journal

  16. The result

  17. Visual Basic in Excel • Visual basic hides behind Excel Macros • If you know any version of VB then it is not difficult to learn the other versions • VB looks horrible in Excel programs, but can be very useful

  18. A simple task for VB in Excel • Find the distance, in metres, between all pairs of a set of 34 US Chemistry departments • This is 1,089 distances – how can it be done?

  19. Solution 1 • Get the coordinates of each department by entering its Zip code into Multimap.com • Enter the coordinates into an Excel spreadsheet • Write a VB program to use this data to calculate the distances between all pairs of departments

  20. The code

  21. How to write a Visual Basic program: Plan A • Think about EXACTLY what you want to do • Can it be fully automated, or will it require human judgement? • Write down EXACTLY what you want to do • Break it into a series of steps • Take VB101 and learn VB • Write the program • Test the program to make sure that it works

  22. How to write a Visual Basic program: Plan B [Quick Version] • Think about EXACTLY what you want to do • Can it be fully automated, or will it require human judgement? • Write down EXACTLY what you want to do • Break it into a series of steps • Find a VB programmer • Ask them to write the program for you • Test the program to make sure that it works • Buy them lunch

More Related