ARTICLE

Replace method in vb.net

Posted by Sapna Articles | Visual Basic Language June 24, 2011
String.Replace () method used to put new string in the place of another string.
Download Files:
 
Reader Level:

String.Replace () method used to put new string in the place of another string. String.Replace () method take two argument. First argument take old value of string and second argument take new value of string.

 Syntax: String.Replace (string1, string2)

img.gif

 
Module Module1
 
     Sub Main()
         Dim userInput As String = "My name is Clark. I am living in Cape Town in South Africa" & vbLf & vbLf
         Console.WriteLine(userInput) 
         Console.WriteLine("What do you want to change?")
         Dim str1 As String = Console.ReadLine() 
         Console.WriteLine("Enter your new value:")
         Dim str2 As String = Console.ReadLine() 
         userInput = userInput.Replace(str1, str2)
         Console.WriteLine(userInput) 
         Console.WriteLine("What do you want to change?")
         str1 = Console.ReadLine()
         Console.WriteLine("Enter your new value:")
         str2 = Console.ReadLine()
         userInput = userInput.Replace(str1, str2)
         Console.WriteLine(userInput)
         Console.ReadLine()
     End Sub 

 End
Module 

 Output 

Untitled-1.gif

 Figure 1

Login to add your contents and source code to this article
share this article :
post comment
 

Helpful Article

Posted by Shalini Juneja Jun 27, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
Become a Sponsor