VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Fix Apostrophe in strings for SQL query

by Bobby (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

Fix Apostrophe in strings for SQL query

Inputs
String as input to the function
Code Returns
Returns the modified string

Rate Fix Apostrophe in strings for SQL query

Function Fix_Apostrophe(ByVal S As String) As String
  Dim i As Integer, ch As String, Ret As String
  If IsNull(S) Then Exit Function
  Ret = ""
  For i = 1 To Len(S)
    ch = Mid$(S, i, 1)  ' the current charcater
    Ret = Ret & ch
    ' If the character is a single quote add a second one.
    If ch = "'" Then
     Ret = Ret & ch
    End If
  Next
  Fix_Apostrophe = Ret
End Function

Download this snippet    Add to My Saved Code

Fix Apostrophe in strings for SQL query Comments

No comments have been posted about Fix Apostrophe in strings for SQL query. Why not be the first to post a comment about Fix Apostrophe in strings for SQL query.

Post your comment

Subject:
Message:
0/1000 characters