Tutorial 2 - Copyright Screen

Tutorial 2 - Copyright Screen

Tutorial Sheet 2/Week 3

IMS1906: Business Software Fundamentals

Tutorial exercises

Week 3: Creating a copyright Screen

These notes are available on the IMS1906 Web site

Please contact your tutor if you require assistance with these exercises. Tutor email address and consultation times are available on the subject’s Web page under Staff.

TaskTo design and create a splash screen.

Aims

  • To gain experience and familiarity with VB.NET IDE
  • To manage a VB.NET application,
  • the use objects: label, picture Box, command button
  • to code the behaviour of the Exit button

Description

Imagine you have been asked to write some software for "Specialised Software Company". Your software will include a copyright screen which contains information like your name and the date the software was created, with a command button to exit.

Contents of Copyright screen

The copyright screen contains 2 label objects, 1 command button, and a picture Box object. To create this application you will need to:

  1. Create the interface (get it looking right)
  2. Refine the interface (by setting property values at design time)
  3. Program its detailed behaviour (by using code to be read during run time)

Double click the appropriate objects from the toolbox, and position them neatly on the form. Next you need to set some property values.

Setting Property Values at Design time

Form:

The name property of the form should be frmCopyright (for this application there is only one form, other applications may have several forms and it is important to give them sensible names to make your code readable). The text property is what is written in the title bar and should be Specialised Software Company. Experiment with different colours for the form through the BackColor property. Just click on the three dots and then choose a colour.

Button:

Its name property should be btnExit or something meaningful (make sure it starts with cmd). Its text property should be Exit.Modify the fontproperty set size to be 12 and the font style to bold.

Label object:

The first label contains your name information: its name property should be lblName, its text should be Written by (your name). Experiment with different font sizes and styles. The second label contains the date, so call it something like lblDate. Its text property should be Copyright 2005. Again, experiment with font properties.

Picture Box object:

You should set the name property to be picBoxComputer if you are using a computer icon, or something similar. You will need to insert an image on the form using the image property (once you have positioned the picture Box where you want it). Search through the directories to find a picture you like. Perhaps you have a suitable picture file on a floppy disk? Make sure you set the SizeMode property to StretchImage so that the image fills the resized image control completely.

Coding the button's behaviour

Now that you have got the interface looking right, and all the property values have been set, it is time to code its detailed behaviour. What do we want the application to do when we interact with it? In this application, the only way we (as users) can interact is to click the command button. When the command button is clicked, we want the application to end. How do we achieve this?

Double click the command button, and a code window will open. This is where Visual Basic.NET will read from if the command button is clicked. Type the instruction Me.Close()or Close()in the subroutine so that the code looks like:

PrivateSub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

Close()

EndSub

Notice that the object is btnExit (your command button) and the event is click. Thus this code will be read only if the command button is clicked. Close() or Me.Close() is a predefined Visual Basic method which tells VB to stop running the application.

Run the application

Now run the application by clicking the start(or play) button on the toolbar. You will be in run mode. Click your command button to exit and you will revert to design mode.

If you get an error message saying “Main Sub was not found”, then go back and set the start object to the name of the form. Do this by right-clicking on the project name in the solution Explorer Window, then selecting Properties. A window will appear , change the startup Object to the name of your form.

Saving your work

You have now finished your first Visual Basic application. To save your work click File on the menu bar and then click Save All. Alternatively, click the Save All button on the Standard Toolbar

Exercise 2

Multi-choice Questions from Zak p35 [Q6,Q7, Q8, Q9,Q13,Q14, Q17,Q18,Q19, Q20]

Discussion Questions Zak p37 {Q1, Q2, Q6, Q7]

Coding-research question Zak p39 Q11

Exercise 3

The Visual Basic.NET Integrated Development Environment is given in the attachedAppendix.

Place labels on the diagram to identify the following windows:

  • Solution Explorer Window
  • Main Window
  • Toolbox Window
  • Windows Form Designer Window
  • Properties Window
  1. What is the solution explorer window used for?
  2. What is the Windows form designer window used for?
  3. What does the toolbox contain?
  4. What is the purpose of the properties window?
  5. List the bars that are found at the top of the main window.

Appendix – VB.NET Integrated Development Environment

MonashUniversity – SIMS
IMS1906 Lecturer: tel: 9903 1911

Page 1 of 4