In this post, am going to show you
String.Equals,String.Replace, and String.Insert Methods in Visual Basic
The Equals() method can be used in place of the "=" when comparing one string against another.
If the comparison has a match, true will be returned while false if no match found.
It has the following syntax;
String.Equals(expression)
If dURL.Equals("www.emmason247.com.ng") Then
MessageBox.Show()
Else
MessageBox.Show("No match found")
End If
You might also like
Visual Basic Substring
The replace method is mostly used when you want to replace text in one string with some another text. The process is fairly straightforward.
It has the following syntax
String.Replace(Expression, Replacement)
In the Replace method syntax, Expression means the text that contains what you intend to replace why the Replacement means replacement string
Here's some code that uses replace. Add a button to a form and test it out:
Dim str As String = "Welcome to Emmason"
str = str.Replace( "Emmason", "Emmason Community" )
MessageBox.Show(str)
If you run the code now, you will see a message box saying"Welcome to Emmason Community" instead of "Welcome to Emmason"
You can also check
Split() in VB
The visual basic Insert () method is used to insert new text into an existing text.
String.Insert(startIndex, newText)
The start index means where the method will start is positioning from while new Text is the text that is to be inserted
Dim str As String = "I Emmason247.com.ng"
str = str.Insert(2, "love")
MsgBox(str)
Output
I love Emmason247.com.ng
The 2 in round parenthesis means start at position 5 in the string variable str (the count starts at zero).