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

Normalizing strings (Trim and case)

This lesson covers normalizing strings in VB.NET, with the aim of comparing text that is written inconsistently.

Trim() removes stray whitespace from both ends and ToLower() unifies the case. Together these are called normalization — making strings that look different but mean the same thing compare as equal.

The sample code runs s.Trim().ToLower() inside a Normalize() function, stripping the surrounding whitespace and then lower-casing. Two strings that look different — " Hello World " and "hello world" — compare as the same once normalized.

A common early stumble is comparing without normalizing and producing the bug where two strings that should match do not, because of stray whitespace or a difference in case.

In professional work, normalization is an indispensable preprocessing step wherever inconsistent input is likely — comparing search keywords or email addresses.

๐Ÿ“– 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)