by Iain Baughen (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 12th January 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Enclose a given string in single quotes, double quotes or hashes (useful for database work) with one simple function
'usage example:
'addquotes(MyString, 2) will enclose myString in double quotes
'addQuotes("test",1) will enclose test with single quotes
Public Function addQuotes(strString As String, quoteType As Byte) As String
Dim strQuote As String
Dim newString As String
Select Case (quoteType)
Case Is = 1
strQuote = "'"
Case Is = 2
strQuote = Chr(34) ' set " quote
Case Is = 3
strQuote = "#"
End Select
newString = strQuote & strString & strQuote
addQuotes = newString
End Function
No comments have been posted about Enclose a given string in single quotes, double quotes or hashes (useful for database work) with on. Why not be the first to post a comment about Enclose a given string in single quotes, double quotes or hashes (useful for database work) with on.