VB.NET Windows Forms Examples — Binary Clock in Visual Basic ✨

Visual Basic learning workspace with small, interactive Windows Forms experiments.

Language: Visual Basic Framework: .NET Framework UI: Windows Forms

Overview

This repository is a compact collection of Visual Basic .NET (VB.NET) Windows Forms projects focused on UI design, patterns, and experimentation in the classic desktop ecosystem. It currently includes one sample project: a binary clock that shows the current hour, minute, and second as coloured binary blocks, updated live by a timer.

It is useful if you are learning VB.NET and want a small, readable example of timer events, binary number conversion, and mouse-driven form interaction.

Repository structure

vb_codes/
├── .gitignore
├── README.md
└── Observer Pattern/
    ├── Observer Pattern.sln
    └── Observer UI/
        ├── My Project/
        ├── Observer UI.vbproj
        ├── Observer.vb
        ├── Observer.Designer.vb
        └── Observer.resx

What it does

The project in the Observer Pattern folder is a Windows Forms application (FormBinary) that visualizes the current time using a binary-style layout:

  • Red blocks represent the hour
  • Yellow blocks represent the minute
  • Green blocks represent the second
  • The hour uses five blocks (weights 16, 8, 4, 2, 1); the minute and second each use six blocks (32, 16, 8, 4, 2, 1)
  • A label above the blocks also shows the time as text, and the display updates in real time

Visual behavior

  • The form is draggable with the left mouse button
  • Double-clicking the window closes the app
  • The timer refreshes the display every second
  • Binary digits are calculated programmatically by subtracting powers of two (2 ^ n)

Core idea

This project is a simple and intuitive example of using UI components, timer events, and custom colouring logic in VB.NET to build a live, animated interface without complex frameworks.

How the binary conversion works

On every timer tick, SetColourIndex takes the hour, minute, or second and walks the powers of two from 2 ^ 5 (32) down to 2 ^ 0 (1). Whenever the remaining value is at least the current power, that bit is switched on and the power is subtracted. SetBackColour then colours the matching blocks. For example, 45 seconds is 32 + 8 + 4 + 1, so the 32, 8, 4, and 1 blocks turn green.

Project details

Item Value
Language Visual Basic (.NET Framework)
UI Framework Windows Forms
Main file Observer Pattern/Observer UI/Observer.vb
Solution file Observer Pattern/Observer Pattern.sln
Build target .NET Framework 2.0
Purpose Timer-driven UI and binary-number demonstration

How to run it

Visual Studio

  1. Use Windows and a Visual Studio/MSBuild installation that can build the project’s legacy .NET Framework 2.0 target.
  2. Open Observer Pattern/Observer Pattern.sln and build the solution. Modern Visual Studio versions may require a separately reviewed retargeting change; this repository still targets .NET Framework 2.0.
  3. Press F5 to run the app.

The folder name Observer Pattern is historical. The implementation uses Windows Forms events and a timer; it does not define a separate subject/observer abstraction.

Compiled binaries are not stored in the repository, so build the project to get Observer.exe in the bin folder.

Technologies used

  • Microsoft Visual Studio
  • VB.NET
  • .NET Framework 2.0
  • Windows Forms
  • System.Windows.Forms.Timer

Learning value

This project helps practice:

  • event-driven programming
  • timer-based UI updates
  • form interaction and drag behavior
  • binary number logic
  • GUI state updates in Visual Basic

Future ideas

This repository could grow with more Windows Forms experiments such as:

  • calculator apps
  • digital clock widgets
  • student management dashboards
  • data-entry forms
  • game UI prototypes
  • pattern-based visual demos
  • C# and .NET code examples — includes a high-DPI Windows Forms example in .NET 8
  • Glass.Message — a modern MessageBox replacement for Windows Forms apps
  • Spectrum — a real-time audio spectrum analyzer built with Windows Forms

Built with passion for Visual Basic ✨

Small projects, bold ideas, and creative UI experiments.


Read all VB.NET Windows Forms Examples guides online · Project overview · All developer projects