Cambridge IGCSE & O Level Computer Science Programming Book for Microsoft Visual Basic Sample

Page 26

We are working with Cambridge Assessment International Education towards endorsement of this title. Any references or material related to answers, grades, papers or examinations are based on the opinion of the author(s). CAMBRIDGE IGCSE™ & O LEVEL COMPUTER SCIENCE: PROGRAMMING BOOK

Designing the interface As with many other design applications (for example, website builders), the Windows Forms application allows you to design your graphical user interface using a drag and drop technique rather than writing code. You will have to code what the interface does later once you have designed it.

Use the same process to generate a textbox object

LE

Find the button object ab Button in the Toolbox. Click to select the tool and move the mouse over the form in the main design window. The mouse icon will change to show the icon of the selected tool. Click and drag will generate a button on the form. Using the standard Windows mouse controls, it is possible to resize and move the button. abl

TextBox on the form.

M

P

The form will initially look like Figure 1.14. We will customise this by changing the properties of the individual elements.

Figure 1.14: Initial form design

S

A

It is considered good practice to give objects meaningful identifiers. An identifier is the name of the object. The default identifier structure is the type of object followed by a number. The number increases depending on how many objects of that type are on the form, such as Button1, Button2, and so on. The Properties window provides the interface to change the properties of each object. As you select an object on the form, or the actual body of the form itself, the Properties window will change to reflect the properties of the object or form. Objects have many properties that can be configured by the designer, but we are initially only interested in the properties in Table 1.4. Use these properties to personalise the button and textbox.

TIP

When giving objects identifiers (names), it is good practice to start the identifier with capital letters that describe the type of object followed by a meaningful name. For example, BTNShow for the button used to show the ‘Hello World’ message. Putting the type description at the start will mean that when you type BTN on the code interface, the autocomplete will show all the buttons on your form. You could also start the identifiers of all textboxes with the letters TB followed by a meaningful name.

14 Original material © Cambridge University Press 2021. This material is not final and is subject to further changes prior to publication.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.