January 1, 2005

WinTask - Stuff$

'
' Stuff$()
'
' Author: Joe Strazzere
'

'
' Stuff$(Target$, iPos, iLen, Replace$)
'
' Replace iLen characters in the target string Target$, beginning at iPos
' with the string Replace$

Function Stuff$(Target$, iPos, iLen, Replace$)
    Stuff$=Left$(Target$, iPos-1)+Replace$+Right$(Target$, Len(Target$)-iPos-iLen+1)
EndFunction

Msgbox("Insert   "    +Stuff$("abcdef",2,0,"123"),,"Stuff$")    ' a123bcdef
Msgbox("Replace   "    +Stuff$("abcdef",2,3,"123"),,"Stuff$") ' a123ef
Msgbox("Delete   "    +Stuff$("abcdef",2,2,""),,"Stuff$")  ' adef
Msgbox("Replace/Insert   "+Stuff$("abcdef",2,1,"123"),,"Stuff$") ' a123cdef
Msgbox("Replace/Delete   "+Stuff$("abcdef",2,4,"123"),,"Stuff$") ' a123f