Autor Tema: Alternative Replace & Right Functions  (Leído 1856 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Cudder

  • Bytes
  • *
  • Mensajes: 26
  • Reputación: +0/-1
    • Ver Perfil
Alternative Replace & Right Functions
« en: Noviembre 07, 2012, 04:43:28 pm »
Hey boys! I wondered if anyone would help coding an alternative Replace and Right functions as they could be/get detected. This is how I'm using them:

Código: [Seleccionar]
strNewFile = Replace(strNewFile, Right(strFilePath, 4), ".txt")
Maybe we can use other functions to do the same thing or we can code alternative functions. I've found an alternative Replace function in my HDD but it uses Mid / Left / InStr so it's not really good.

Código: [Seleccionar]
Function AltReplace(stExpression As String, stFind As String, stReplace As String) As String
Dim lnStart As Long, lnCount As Long
lnStart = Len(stFind)
AltReplace = stExpression
Do
lnCount = InStr(1, AltReplace, stFind)
If lnCount = 0 Then Exit Do
If lnStart = Len(stReplace) Then
     Mid(AltReplace, lnCount, lnStart) = stReplace
Else
     AltReplace = Left$(AltReplace, lnCount - 1) & stReplace & Mid$(AltReplace, lnCount + lnStart)
End If
Loop
End Function

It would be great if you could help coding alternative funcs using bytearray and it must not use any VB function (Len/Chr/Asc/Space are OK)

Thanks A lot !