Visual Basic .NET - Sub

In VB.NET, a Sub is a procedure or method that performs a specific task without returning a value. It is similar to a function, but it does not return any value. A Sub can take input parameters and perform some operations on them.

Access_Modifier Sub Procedure_Name(Parameter_List)
   'Statements
End Sub

Here, Access_Modifier is the access level of the Sub, Procedure_Name is the name of the Sub, and Parameter_List is the list of input parameters that the Sub will accept.

Sub DisplayMessage(name as String)
    Console.WriteLine("Hello, " & name & "!")
End Sub
'Calling the Sub
DisplayMessage("John")

In this example, the Sub DisplayMessage takes a string parameter name and displays a message with the parameter value. The Sub is called with the argument "John".

Note that since a Sub does not return any value, it cannot be used in an expression. Its purpose is to perform a task, such as displaying a message, modifying a variable, or performing some other action.