122x Filetype PDF File size 2.22 MB Source: www.tanghin.edu.hk
Contents Chapter 1 Ideas of Programming ........................................................................................ 4 1.1 What is a program? ............................................................................................ 4 1.2 What is programming?....................................................................................... 4 1.3 What is a programming language? ..................................................................... 5 1.4 Compilers........................................................................................................... 5 1.5 Names of some programming languages ........................................................... 6 Chapter 2 Visual Basic 2010 Express ................................................................................... 8 2.1 Download Visual Basic 2010 Express .................................................................. 8 2.2 Register Visual Basic 2010 Express within 30 days .............................................. 8 2.3 Your first project ................................................................................................ 9 2.3.1 Create and save a new project ............................................................... 9 2.3.2 Introduction to Visual Basic 2010 IDE ................................................... 11 2.3.3 Adding controls and code ..................................................................... 12 2.3.4 Open an existing project ....................................................................... 13 2.4 Structure of a Visual Basic 2010 project ........................................................... 14 2.5 Microsoft Developer Network (MSDN)............................................................. 14 Chapter 3 Working with Controls ..................................................................................... 15 3.1 Introduction to GUI programming in Visual Basic ............................................. 15 3.2 Controls ........................................................................................................... 15 3.3 Properties window ........................................................................................... 16 3.4 Changing properties at runtime ....................................................................... 17 3.5 Assigning values to properties ......................................................................... 18 3.6 Add a comment to your source code ............................................................... 19 Exercise 3 .................................................................................................................... 19 Chapter 4 Events and Methods ........................................................................................ 20 4.1 Introduction to events and methods ................................................................ 20 4.2 Events .............................................................................................................. 20 4.2.1 Introduction to event procedures ......................................................... 20 4.2.2 Adding an event procedure in Visual Basic ........................................... 21 4.2.3 Names and types of events .................................................................. 22 4.2.4 The structure of an event procedure .................................................... 23 4.2.5 TextChanged events ............................................................................. 23 2 4.3 Methods .......................................................................................................... 24 Exercise 4 .................................................................................................................... 26 Chapter 5 Variables, Input and Output ............................................................................. 27 5.1 Variables .......................................................................................................... 27 5.1.1 Declaring variables with Dim statement ............................................... 27 5.1.2 Keywords and names of variables......................................................... 28 5.1.3 Giving values to variables in the Dim statement ................................... 28 5.1.4 Declaring several variables in a single line ............................................ 28 5.1.5 Using variables to store values ............................................................. 29 5.1.6 Scope of variables ................................................................................ 30 5.2 Introduction to InputBox and MsgBox.............................................................. 32 5.2.1 InputBox ............................................................................................... 32 5.2.2 MsgBox ................................................................................................ 33 5.2.3 Miscellaneous examples ....................................................................... 34 Exercise 5 .................................................................................................................... 34 Chapter 6 Operators and Expressions............................................................................... 35 6.1 Arithmetic Operators ....................................................................................... 35 6.2 Parentheses (singular: parenthesis) ................................................................. 36 6.3 Concatenation Operators ................................................................................. 36 6.4 Operator Precedence ....................................................................................... 37 6.5 Increment and Decrement ............................................................................... 38 6.6 Val function ..................................................................................................... 38 6.7 Mathematical Constants and Functions ........................................................... 39 6.8 Miscellaneous Examples .................................................................................. 40 Exercise 6 .................................................................................................................... 41 Chapter 7 Flow Control (1) ............................................................................................... 42 7.1 Decision Making............................................................................................... 42 7.2 Relational Operators ........................................................................................ 42 7.3 If...Then...Else Statement ................................................................................. 43 7.4 Multiple conditions with keyword ElseIf .......................................................... 44 7.5 Official Syntax of If...Then...Else Statement ...................................................... 46 Exercise 7 .................................................................................................................... 47 Alphabetical Index............................................................................................................... 48 3 Introduction to Visual Basic Chapter 1 Ideas of Programming 1.1 What is a program? A program is a set of instructions that tells a computer how to do a task. With programs, automatically repeatedly computers can perform tasks __________________ and ___________________. 1.2 What is programming? Programming is the process of designing, writing, testing and debugging (remove mistakes) a program. To write a program, you need to know and solve the problem first. After solving the problem, you tell the computer how to solve the problem using a programming language. For example, if you need to write a program that calculates percentage changes, you should first solve the problem by obtaining the formula of percentage change. After that, you will write a program to do the task. In this course, Visual Basic.net the programming language you use. To get the idea of how to create a computer Define the program, you may refer to Problem the diagram at the right. (Note: after having a Solve the finished program, you can Evaluation Problem do an evaluation to look for possible improvements.) Testing and Write a Debugging Program 4
no reviews yet
Please Login to review.