QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

a REMOVE$ function

December 24 2011 at 11:45 AM
AlGoreIthm  (Login AlGoreIthm)

 

Qbasic programmers can append strings or 'concatenate' by using the '+' sign between two strings.
But what about a function to REMOVE a section of string?

Very simple and very useful for string manipulations:
(for best results, copy and paste into a .txt file, then save as a .bas file)
===============================================================================

DECLARE FUNCTION REMOVE$ (a$, st$)

a$ = "Marcus Smith"
st$ = "arc"

a$ = REMOVE$(a$, st$)

PRINT a$;

FUNCTION REMOVE$ (a$, st$)

z% = INSTR(a$, st$)

IF z% THEN REMOVE$ = LEFT$(a$, z% - 1) + RIGHT$(a$, LEN(a$) - (z% + LEN(st$)) + 1) ELSE REMOVE$ = a$

END FUNCTION


 
 Respond to this message   
Responses

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement  

Newbies usually go to www.qbasic.com and click on The QBasic Forum
Forum regulars have their own ways, which include The QBasic Community Forums