Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
395 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
| Software ==> | Visual Basic (46 exercises) |
| Topic ==> | Creating classes (4 exercises) |
| Level ==> | Relatively easy |
| Subject ==> | Visual Basic training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
Right-click on your project in Solution Explorer and choose to add the form from the above folder (you can alternatively press SHIFT + ALT + A ).

The initial form. The idea is that when you type in an item and click on the Add Item button, it will be added to the list on the right.
First add code to the Cancel button so that clicking on it closes the form.
Remember that you can use me to refer to the current form.
Create a class called ShoppingList. Within this, create 3 simple properties, to hold the item name, unit and amount. Here's an example for the item name:
'item name property
Private _ItemName As String = ""
Public Property ItemName As String
Get
Return _ItemName
End Get
Set(value As String)
_ItemName = value
End Set
End Property
You should now be able to attach code to the Add Item button which:
The only thing you need to add now is the code to add the item to the textbox on the right of the form. To do this you could add a public method to your class, which passes in the textbox to which you want to add text:
Public Sub Add(ListTextBox As TextBox)
'add a blank line if appropriate
If ListTextBox.Text.Length > 0 Then _
ListTextBox.Text &= vbCrLf
'add item to the list of items
ListTextBox.Text &= Amount.ToString("0.00") & _
" " & Unit & " of " & ItemName
End Sub
Make sure that you call this method at the end of your Add Item button code, and test your system to check that it accumulates items to buy:

You'll gradually accumulate items in your list.
Test that your system works, then close the form down (don't worry for now that this will then lose your shopping list!).
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2026. All Rights Reserved.