VB.Net program to demonstrate the RTrim() function

Here, we are going to demonstrate the RTrim() function in VB.Net.
Submitted by Nidhi, on December 04, 2020 [Last updated : March 05, 2023]

RTrim() function in VB.Net

The RTrim() function is used to remove the blank space from the right side.

Syntax

RTrim(str)

Parameter(s)

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

Return Value

The RTrim() function will return a string after removing blank space from the right side.

VB.Net code to demonstrate the example of RTrim() function

The source code to demonstrate the RTrim() function is given below. The given program is compiled and executed successfully.

'VB.Net program to demonstrate the RTrim() function.

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#
Press any key to continue . . .

Explanation:

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

str2 = RTrim(str1)

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

VB.Net Basic Programs »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.