@coders
Could you guys make the left() & right() statements , so you can set values for them??
Like:
left( string , 5 ) = "Hello"
right( string , 3 ) = "End"
Like the mid() statement....
LEFT() & RIGHT()
Re: LEFT() & RIGHT()
To be honest, I always used Left and Right as functions, never as SUBs, in fact I have a Replace() function when I need to change some substrings
Code: Select all
FUNCTION Replace (Query AS STRING, LookFor AS STRING, ReplaceWith AS STRING) AS STRING
DIM AS INTEGER FoundPos, StartPos, NextPos
DIM AS STRING LeftStr, RightStr, Result
Result = Query
DO
FoundPos = INSTR(Result, LookFor)
IF FoundPos <> 0 THEN
StartPos = FoundPos - 1
NextPos = FoundPos + LEN(LookFor)
LeftStr = LEFT(Result, StartPos)
RightStr = MID(Result, NextPos, LEN(Result))
Result = LeftStr + ReplaceWith + RightStr
ELSE
EXIT DO
END IF
LOOP
Replace = Result
'Clean memory
Result = ""
END FUNCTION
Re: LEFT() & RIGHT()
Code: Select all
Dim As String test="What a wonderful world"
Mid(test, 1, 2)="Th"
print test
Mid(test, Len(test)-4, 4)="word "
print test
sleep