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

VB.Net program to demonstrate the RTrim() function

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

To remove the blank space on the right side, the RTrim() function is used.

Syntax :

RTrim(str)

Parameters :

  • Str : a string that has been specified that may contain blank space on the right side.

Return Value :

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

Program :

The source code to demonstrate the role of RTrim() 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 = RTrim(str1)
        Console.WriteLine("Right Trimmed string: #{0}#", str2)
    End Sub
End Module
	
Output:
Right 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 = RTrim(str1)

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


No Sidebar ads