Home >>VB.Net Built-in Functions >VB.Net program to demonstrate the LTrim() function

VB.Net program to demonstrate the LTrim() function

Write a VB.Net program to demonstrate the LTrim() function

To remove the blank space on the left side, the LTrim() function is used.

Syntax :

LTrim(str)

Parameters :

  • Str: a string that is specified and may contain blank space on the left or right side.

Return Value :

  • After removing blank space from the left side, the LTrim() function will return a string.

Program :

The source code for demonstrating the function LTrim() is given below. The program given is compiled and successfully executed.


Module Module1
    Sub Main()
        Dim str1 As String = " I love india "
        Dim str2 As String = ""
        str2 = LTrim(str1)
        Console.WriteLine("Left Trimmed string: #{0}#", str2)
    End Sub
End Module
	
Output:
Left Trimmed string: #I love india #

Explanation:

We created a Module1 module in the program above that contains the Main() method. We have created two variables str1 and str2 in the Main() method, where variable str1 is initialized with " I love india " and variable str2 with a blank string is initialized.

str2 = LTrim(str1)

We used the LTrim() function in the code above, which will return the string after removing space from the left side. Then, on the console screen, we printed the string.


No Sidebar ads