Remove All Whitespace in Visual Basic

Published on 07 May 2026 (Updated: 07 May 2026)

Welcome to the Remove All Whitespace in Visual Basic page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

Public Module RemoveAllWhitespace

    Private Sub ShowUsage()
        Console.WriteLine("Usage: please provide a string")
        Environment.Exit(1)
    End Sub


    Private Sub RemoveAllWhitespace(input As String)

        Dim result As New System.Text.StringBuilder()

        For Each ch As Char In input

            If Not Char.IsWhiteSpace(ch) Then
                result.Append(ch)
            End If

        Next

        Console.WriteLine(result.ToString())

    End Sub


    Public Function Main(args As String()) As Integer

        If args Is Nothing OrElse args.Length = 0 OrElse String.IsNullOrEmpty(args(0)) Then
            ShowUsage()
        End If

        RemoveAllWhitespace(args(0))

        Return 0

    End Function

End Module

Remove All Whitespace in Visual Basic was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.