160 likes | 251 Views
Programming. Visual Basic. Programming. This is the final evidence you require to gather for you folio. You need 2 programs at the best level you can. Aim high as a good mark for Practical Abilities can improve your overall grade!. Lesson 1: Learning Intentions.
E N D
Programming Visual Basic Standard Grade Programming using VB
Programming • This is the final evidence you require to gather for you folio. • You need 2 programs at the best level you can. • Aim high as a good mark for Practical Abilities can improve your overall grade! Standard Grade Programming using VB
Lesson 1: Learning Intentions • To understand that VB is a programming language • To understand that a program is a list of instructions • To understand that a VB project is made up of a project, a form, and controls. • To understand how to run a VB program • To understand how to stop a VB program running Standard Grade Programming using VB
Visual Basic COPY! • VB is a computer programming language, a High Level Language (HLL). A program is a list of instructions that cause a computer to perform a useful task, such as playing a game or writing a letter. • A program can be quite small—something designed to add two numbers together, or it can be a large application, such as Microsoft Word. Staple the VB programming environment into a page in your jotter – learn it! Run the Sample project Standard Grade Programming using VB
Lesson 2: Learning Intentions • Creating and using a command button • Creating and using a picture box • Changing properties of a control using the properties window • Writing a simple piece of VB code • Saving a project in its own folder Standard Grade Programming using VB
The Label Control COPY! • A label is a control that displays information the user cannot edit. It is often used to provide titles on the screen for other controls or to explain what the program does. • The label always has a 3 letter prefix of lbl followed by the name of the label eg a label to display a heading may have the name: lblHeading Standard Grade Programming using VB
The Label Control (cont’d) COPY! Open a new project Name its form as frmName and give it the caption Name Create a label, name the label lblName Change caption to your own name Alter the alignment property Alter BackColor/ForeColour properties • Not the use of the prefix in small letters, followed by the name of the label beginning with a capital letter. Always write names of controls in this way. lblHeading Standard Grade Programming using VB
Lesson 3/4: Learning Intentions • The command button Standard Grade Programming using VB
The Command Button The command button is a Control placed on a form that when clicked runs the code behind that button. The button could cause the code to start, pause, or end an action. Standard Grade Programming using VB
The Command Button Problem Statement We are going to write a program to make the computer beep. When the beep command button is pressed the computer should beep. Standard Grade Programming using VB
The Command Button Design of HCI frmBeep cmdBeep Both the command button and the form have the caption Beep Standard Grade Programming using VB
The Command Button Coding This program only needs one line of code to make it beep. The code is written between the Private Sub and End Sub lines of code eg Private Sub cmdBeep_click() Beep End Sub All commands inside the Private Sub and End Sub lines are indented! Now go to your computer and create this program. Once you have finished it complete the task on page 25 of the VB Pupil Booklet 1. (ie, adding an End and Exit button) Standard Grade Programming using VB
Lesson 5: Learning Intentions • Setting Properties in Run Mode Standard Grade Programming using VB
Setting Properties in Run Mode COPY! When a program is running it is possible to change the properties of a label, picture box or form. To do this we need to use a line of VB programming code. The code must be in the form:- ControlName.PropertyName = PropertyValue Eg frmSample.BackColor = vbRed This code changes the background colour of form frmSample to red Standard Grade Programming using VB
Setting Properties in Run Mode Write the line of code that would change the background colour of the label lblHeading to green: Now load the Beep program and do the task on page 24 of the booklet. Change background colour of Form to Blue and forecolour (text colour) to red. Eg if we wanted to change the background colour of the form called frmSample to red then the code would be: frmSample.BackColor = VBRed Remember: it must take the form:- ControlName.PropertyName = PropertyValue Standard Grade Programming using VB
Setting Properties in Run Mode Eg Standard Grade Programming using VB