week 6

Radio Buttons

Radio buttons are a commonly used feature in most program and websites, these enable the users to make a selection from a possible number of selections, however it is limited to only enabling them to have one choice at a time, so for example the option of a drink for a person in a fastfood resturant would be,

  • Coke
  • Diet Coke
  • Fanta
  • Water

The option of one of this is required as the person is not likely going to want a mixture of all these drinks. A more common and obvious demonstration of this would be Male or Female and Smoker or non smoker.

The example below describes an option of an item of clothing that is of medium price being selected, this triggers a number of things to happen, the first is that the number that the user has input in to the quantity text box (Qtychosen) is assigned to a variable dqty on line ①
The next line then assigns the result of the value set in dmediumprice and multiplys this by the value in dqty and then adds the value set in the variable dpostpack on line ②
The next line then takes the value that is now stored in the dteeprice variable and converts it to a string using Str and outputs this in to the textbox TeePriceBox by using the .text function at the end of the objects name on line ③.
The next line then takes the value now placed in the textbox and changes the format to a currency on line ④
The next line takes the value stored in the variable dteeprice and adds the assigned value of dgiftprice and assigns it to the variable of dtotalprice ⑤
The value now stored in dtotalprice is then made in to a string on line ⑥ and then attached to the TotalPriceBox text box by using .text
Finaly on line ⑦ the value of the textbox TotalPriceBox is formated to a currency

1. dqty = Val(Qtychosen.Text) 2. dteeprice = dmediumprice * dqty + dpostpack 3. TeePriceBox.Text = Str(dteeprice) 4. TeePriceBox.Text = Format(TeePriceBox.Text, "currency") 5. dtotalprice = dteeprice + dgiftprice 6. TotalPriceBox.Text = Str(dtotalprice) 7. TotalPriceBox.Text = Format(TotalPriceBox.Text, "currency")

This instance of a radio button could be simply copied and reused by a user if there were other options within the radio button selection, just as long as the links to the global variables and changed to link to the correct options.

System


Global Variable Declarations

The use of global declarations are key in programming as this will enable modules of seperate code to refer to them without knowing that others also link to them. These are usually found in the uppermost part of the coding area. This could be useful when creating programs like calculators where the value for Pi (π) could be declaired globally so that other operators can access it.

Const dsmallprice As Decimal = 7.5
#

What is the #
#
5 min's

Uploading an image and having a preview

In some programs users are enabled with the ability to add a file to a system, this could be to upload a document relating to a specific user in a database or it could be to enable the user to customise a design for a product like a tee-shirt where a they can add there own images.
The feature will require a number of different tools from our tool box.

picturebox
Step 1: You will need to drag a picture box on to your form design.
choose
Step 2: You will need to drag a button on to the form to enable the user to select the image from thier computer.
choose
Step 3: You will need to drag a textbox on to the form to enable the user to select the image from thier computer.
Step 4: The code! Below we have an example of the code that is used to link the two features together so that we can get our image and to display it to the user.

Explaining the code


1. The event trigger, "Click"
2. Blank
3. The builtin open dialog box is called, the filter on the open file is set to images as a default
4. Display the open file dialog box
5. Assign the value of the file name selected to the textbox "imagename" using the .text function
6. On this line the system function calls the drawing.image.fromfile function where the value is set to the value contained within the "Imagename" text box and attaches it to the Teedesign imagebox as .image

1. Private Sub ChooseButton_Click(sender As System.Object, e As System.EventArgs) Handles ChooseButton.Click 2. 3. OpenFileDialog1.Filter = "Image Files (*.BMP;*JPG)|*.BMP;*.JPG" 4. OpenFileDialog1.ShowDialog() 5. Imagename.Text = OpenFileDialog1.FileName 6. Teedesign.Image = System.Drawing.Image.FromFile(Imagename.Text) 7. 8. ToolTip1.SetToolTip(Imagename, Imagename.Text) 9. End Sub




EXTENTION
Using the graphic editor of your choice create 5 tee shirt images that use the following a there most dominant colour
1. Red
2. White
3. Green
4. Blue
5. Black

EXTENTION
Make your images professional by adding additional detail to them
STRETCH & CHALLENGE


The information covered in this page covers the knowledge and understanding linked to the criterion in the table below.

Links to Assessment Criteria Description
LO1 Understand the features of event driven programming:
Key features: service oriented; time driven; event handlers; trigger functions; events eg mouse, keyboard, HTML object, form, user interface; event loops; flexibility; suitability for graphical interfaces; simplicity of programming; ease of development
LO2 Be able to use the tools and techniques of an event driven language:
Triggers: eg key press, alarm, system event, touch screen event, mouse click
Tools and techniques: eg use of tool boxes and controls, selection, loops, event handlers, triggers, objects and object properties, menus; debugging tools
Variables: declaring variables; scope of variables; constants; data types
Functional Skills English Reading, Writing, Comprhension, Problems Solving, Nouns
Functional Skills Maths Compression,Reduction
British Values None covered in this session.
Equality and Diversity

Last Updated
2018-04-16 13:27:00

Links to Learning Outcomes

Links to Assessment criteria

 


English

0

Maths







How 2's Coverage

0

0

Files that support this week


| | | | |
Week 5
Prev
Week 6
Prev
Week 7
Prev

Next

Next
Webmaster Spelling Notifications