VB Quotes in string

In VB, one solution to add quotes to a string is concatenating the string with the quotes character. The quotes ( and other characters) can be obtained by using Chr(char_code) function. This function
returns a character that is equivalent to the char_code number argument. For a double-quote character the codes are 147 (opening double-quote) and 148 (closing double-quote).

Module Module1

   Sub Main()
     Dim namestr As String
     Dim welstr As String
     Console.Write("What is your name? ")
     namestr = Console.ReadLine()
     welstr = "Hello " & Chr(147) & namestr & Chr(148)
     Console.WriteLine(welstr)
     Console.ReadLine()
   End Sub
End Module

Posted by: Lavy | post date: 02-06-2013 | Subject: VB.NET Programming Language




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.