Mega Code Archive

 
Categories / VB.Net / Data Types
 

Use the Mid function to replace within the string

Imports System Imports System.Collections Public Class MainClass          Shared Sub Main()              Dim s1 As String = "abcd"              Dim s2 As String = "ABCD"              Dim s3 As String = "Liberty Associates, Inc. provides "              s3 = s3 & "custom .NET development"              Dim s5 As String = String.Copy(s2)              Console.WriteLine("s5 copied from s2: {0}", s5)              Dim location As Integer = s3.IndexOf("provides")              ' you can combine the two as follows:              Dim s11 As String = _                  s3.Insert(s3.IndexOf("provides"), "usually ")              'use the Mid function to replace within the string              Mid(s11, s11.IndexOf("usually") + 1, 9) = "always!"              Console.WriteLine("s11 now: {0}", s11)    End Sub End Class