Here are some examples of String Insert, IndexOf, and Format in VB.NET:
- String Insert:
The String Insert function is used to insert a string at a specified position in another string.
Example:
Dim str1 As String = "Hello" Dim str2 As String = "World" Dim result As String = str1.Insert(5, " " & str2) ' Output: "Hello World"
- IndexOf:
IndexOf method returns the position of a specified substring in a given string.
Example:
Dim str As String = "The quick brown fox jumps over the lazy dog"
Dim index As Integer = str.IndexOf("brown")
' Output: 10
- Format:
The Format function is used to format a string by inserting values into placeholders.
Example:
Dim name As String = "John"
Dim age As Integer = 30
Dim result As String = String.Format("My name is {0} and I am {1} years old.", name, age)
' Output: "My name is John and I am 30 years old."