18.01.2013 Views

Tutorial: Programming in Visual Basic 6.0

Tutorial: Programming in Visual Basic 6.0

Tutorial: Programming in Visual Basic 6.0

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

End Select<br />

Activity 6<br />

Is < 6<br />

Case<br />

= “Preschool”<br />

lblTitle.Caption<br />

6 To 11<br />

Case<br />

= “Primary School”<br />

lblTitle.Caption<br />

12 To 18<br />

Case<br />

= “Secondary School”<br />

lblTitle.Caption<br />

Else Case<br />

= “Adult”<br />

lblTitle.Caption<br />

1. The post office has the follow<strong>in</strong>g charges for parcels based upon different weights.<br />

(gram) Cost<br />

Weight<br />

– 50 $1.40<br />

0<br />

– 100 $2.70<br />

51<br />

– 250 $4.00<br />

101<br />

251 – 500 $7.50<br />

Parcels which are heavier than 500 gms are calculated by weight*0.02<br />

a project that allows a user to enter the weight <strong>in</strong> a text box and calculate the<br />

Design<br />

Use Case statements <strong>in</strong> your code. L<strong>in</strong>k this as CaseWeights under the<br />

postage.<br />

Multiway menu head<strong>in</strong>g <strong>in</strong> your ma<strong>in</strong> form.<br />

Use a set of check boxes to allow a user to choose the noise level by the comments,<br />

2.<br />

output the probable decibel level based on <strong>in</strong>formation <strong>in</strong> the follow<strong>in</strong>g table.<br />

then<br />

level Comfort level<br />

Decibel<br />

Extremely pa<strong>in</strong>ful<br />

140+<br />

– 139 Deafen<strong>in</strong>g<br />

90<br />

– 89 Disturb<strong>in</strong>g<br />

60<br />

– 59 Distract<strong>in</strong>g<br />

30<br />

– 29 Relax<strong>in</strong>g<br />

0<br />

use Case statements and l<strong>in</strong>k this to the ma<strong>in</strong> form menu under the name<br />

Aga<strong>in</strong><br />

aga<strong>in</strong> connected to the Multiway menu head<strong>in</strong>g.<br />

NoiseLevels<br />

Activity 7<br />

control array is a set of multiple controls of the same type with the same name (often<br />

A<br />

by us<strong>in</strong>g the Copy and Paste command). You may have encountered this already<br />

created<br />

add<strong>in</strong>g radio buttons or check boxes to your form. Individual controls with<strong>in</strong> the array<br />

<strong>in</strong><br />

dist<strong>in</strong>guished by hav<strong>in</strong>g different Index property values. So, if you created a control<br />

are<br />

of option buttons called optChoice, the Click event procedure might look like this:<br />

array<br />

Private Sub optChoice_Click (Index As Integer)<br />

Select Case optChoice (Index)<br />

Case Index = 0 Label1.Caption = "Monday"<br />

Case Index = 1 Label1.Caption = "Tuesday"<br />

Case Index = 2 Label1.Caption = "Wednesday"<br />

Case Index = 3 Label1.Caption = "Thursday"

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!