Ad space (banner)
๐Ÿ”ทVB.NET Lessons
Lesson 68 / 68

[Project] Build a simple inventory system

This lesson covers building a simple inventory system with VB.NET's Dictionary, with the aim of combining what you have learned so far into a larger program.

Dictionary(Of String, Integer) lets you manage stock levels keyed by product name — a data structure close to what real business code uses. It brings together the variables, loops, and dictionaries covered so far.

The sample code sets values by key, as in items("apple") = 10, reduces the stock with items("apple") -= 3, and lists every product with a For Each statement. Note item.Key and item.Value, which reach the key and the value.

A common early stumble is reaching for a key that does not exist, which is an error. Real work may involve products with zero stock or names not yet registered, so checking with ContainsKey() first is an important habit.

In professional work, managing data keyed by a name or a number — inventory, orders, membership — is the basic shape of a business system, and key-value structures such as Dictionary are used throughout.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run VB.NET directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)