subApostrofo




Public Sub Apostrophize(ByRef s1 As String, _
Optional ByRef s2 As String, _
Optional ByRef s3 As String)

Dim iPos As String
's1

iPos = 1
Do
iPos = InStr(iPos, s1, "'") 'cerca l'apice
If iPos <> 0 Then
s1 = Left(s1, iPos) & "'" & Right(s1, Len(s1) - iPos)
iPos = iPos + 1 'Incrementa puntatore
iPos = iPos + 1 'Incremento meno "'"
End If
Loop Until iPos = 0
's2

If Not IsMissing(s2) Then
iPos = 1
Do
iPos = InStr(iPos, s2, "'")
If iPos <> 0 Then
s2 = Left(s2, iPos) & "'" & Right(s2, Len(s2) - iPos)
iPos = iPos + 1
iPos = iPos + 1
End If
Loop Until iPos = 0
End If
's3

If Not IsMissing(s3) Then
iPos = 1
Do
iPos = InStr(iPos, s3, "'")
If iPos <> 0 Then
s3 = Left(s3, iPos) & "'" & Right(s3, Len(s3) - iPos)
iPos = iPos + 1
iPos = iPos + 1
End If
Loop Until iPos = 0
End If
End Sub

'***NOTA***

'In VB 6, potete utilizzare questo facile codice

'sCommand=Replace(sCommand,"'","''")











( subapostrofo.html )- by Paolo Puglisi - Modifica del 17/12/2023