eller : Public Function Replace(ByVal vntValue As Variant, ByVal strSource As String, ByVal strDest As Variant) As Variant \'Purpose Replace part of a string by another. \'Inputs vntValue Value where execute substitution \' strSource String to replace \' strDest String replacement \'Assumes \'Returns \'Effects Dim i, j As Integer Dim intLngDest As Integer, intLngSource As Integer
If IsNull(vntValue) Then Exit Function End If If strSource <> strDest Then intLngDest = Len(strDest) If intLngDest = 0 Then intLngDest = 1 End If intLngSource = Len(strSource)
i = 1 j = InStr(i, vntValue, strSource) While j <> 0 vntValue = Left(vntValue, j - 1) & strDest & Right(vntValue, Len(vntValue) - (j + intLngSource - 1)) i = j + intLngDest j = InStr(i, vntValue, strSource) Wend End If Replace = vntValue End Function
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.