Check if Strings Contains Replacing Sub Strings in VB.Net

This Tutorial is all about Check if Strings Contains Replacing Sub Strings in VB.Net. In this tutorial you will learn about Check if Strings Contains Replacing Sub Strings in VB.Net. So lets get Started:

  • String.Contains is a method used when you want to check whether a specified sub string occurs within the string. It returns True if the value parameter occurs within the string, otherwise it returns False.
  • The String.Replace is a method used when you want to replace all occurrences of a specified string with another specified string. It returns new string that is the same as the current string except that all instances of old Value are replaced with new Value. If oldValue is not found this method returns the same string unchanged.
  • Try this code:
    Dim OriginalString As String = "Hello User"
    Dim ModifiedString As String = String.Empty;
    If OriginalString.Contains("Hello") Then
    ModifiedString = OriginalString.Replace("Hello", "Good Bye")
    Console.WriteLine(ModifiedString) ' = Good Bye User"
    End If

If you have any comments or suggestions about on Check if Strings Contains Replacing Sub Strings in VB.Net, please feel free to contact our webpage.

Other Articles Readers might read:

Leave a Comment