How to VB.NET String.EndsWith()

The EndsWith method in VB.NET's String Class provides a convenient way to determine whether a given string ends with a specified string. By using the EndsWith method, you can check if the target string's ending portion matches the provided string.


The EndsWith method returns a Boolean value, indicating whether the target string ends with the specified string. It allows you to perform conditional logic or make decisions based on the result of this comparison. If the target string's ending portion matches the provided string, the method returns true; otherwise, it returns false.

System.String.EndsWith(String suffix) as Boolean
  1. suffix - The passing String for it EndsWith .
  1. Boolean - Yes/No

If the String EndsWith the Parameter String it returns True

If the String doesnt EndsWith the Parameter String it return False

For ex : "This is a Test".EndsWith("Test") returns True

"This is a Test".EndsWith("is") returns False

System.ArgumentNullException: If the argument is null.

By utilizing the EndsWith method, you gain the ability to perform precise checks on string endings, enabling you to handle or process strings in a more controlled and accurate manner. This method enhances the flexibility and efficiency of string manipulation, especially when dealing with patterns or specific criteria related to the ending portion of strings.

Full Source VB.NET
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str As String str = "VB.NET TOP 10 BOOKS" If str.EndsWith("BOOKS") = True Then MsgBox("The String EndsWith 'BOOKS' ") Else MsgBox("The String does not EndsWith 'BOOKS'") End If End Sub End Class


The EndsWith method in the VB.NET String Class facilitates the evaluation of whether a target string ends with a specified string. This functionality empowers developers to perform string validations, filtering, or other operations based on the ending portion of strings in their VB.NET applications.