Apr 27, 2011 #1 rcr22b Vendor Apr 27, 2011 3 US This may be simple problem for some of you but it has me stumped: CLS ctr = 1 ctr$ = STR$(ctr) a$ = a$ + "000" + ctr$ PRINT a$ END What I get is 214275000 1. What I want is 2142750001 How can I remove the space from this string?
This may be simple problem for some of you but it has me stumped: CLS ctr = 1 ctr$ = STR$(ctr) a$ = a$ + "000" + ctr$ PRINT a$ END What I get is 214275000 1. What I want is 2142750001 How can I remove the space from this string?
Apr 27, 2011 Thread starter #2 rcr22b Vendor Apr 27, 2011 3 US Let me explain my problem more. I don't care what is printed on the screen. I am comparing two strings from different sources. One string is from a file and does not contain a space. The other sting is generated by my code and I need to remove the space from that string. Thanks. Upvote 0 Downvote
Let me explain my problem more. I don't care what is printed on the screen. I am comparing two strings from different sources. One string is from a file and does not contain a space. The other sting is generated by my code and I need to remove the space from that string. Thanks.
Apr 27, 2011 1 #4 Bluejay07 Programmer Mar 9, 2007 780 CA I am not sure if these functions exist in the language you are using, however, you could try: Code: ctr$ = trim$(str$(ctr)) 'Trim removes any leading or trailing spaces. If you have number, space(s) and more numbers, you can use a function similar to: Code: Replace$(ctr$, " ", "") 'Replace any space in the string with nothing, thus it removes all spaces. If at first you don't succeed, then sky diving wasn't meant for you! Upvote 0 Downvote
I am not sure if these functions exist in the language you are using, however, you could try: Code: ctr$ = trim$(str$(ctr)) 'Trim removes any leading or trailing spaces. If you have number, space(s) and more numbers, you can use a function similar to: Code: Replace$(ctr$, " ", "") 'Replace any space in the string with nothing, thus it removes all spaces. If at first you don't succeed, then sky diving wasn't meant for you!
Apr 27, 2011 Thread starter #5 rcr22b Vendor Apr 27, 2011 3 US Thanks to everyone for the help. I knew there had to be a way. Upvote 0 Downvote
Apr 28, 2011 #6 PeterWallace Programmer Apr 28, 2003 210 AU Ctr$= FOMAT(ctr$,"###########") a$ = a$ + "000" + ctr$ Upvote 0 Downvote
Apr 28, 2011 #7 PeterWallace Programmer Apr 28, 2003 210 AU Ctr$= FORMAT(ctr$,"###########") a$ = a$ + "000" + ctr$ Upvote 0 Downvote
Apr 29, 2011 #8 strongm MIS May 24, 2001 20,148 GB >Ctr$= FORMAT(ctr$,"###########") That won't work correctly if the digit after the space is a 0 (and there's nothing in the OP to suggest that it might not be). Mind you, reviewing the original code suggests the whole problem can be avoided by using one of two different conversion techniques: Change [tt]ctr$ = STR$(ctr[/tt]) to [tt]ctr$ = CStr$(ctr)[/tt] or delete [tt]ctr$ = STR$(ctr)[/tt] and change [tt]a$ = a$ + "000" + ctr$[/tt] to [tt]a$ = a$ + "000" + ctr[/tt] (or, perhaps better, [tt]a$ = a$ & "000" & ctr[/tt]) Upvote 0 Downvote
>Ctr$= FORMAT(ctr$,"###########") That won't work correctly if the digit after the space is a 0 (and there's nothing in the OP to suggest that it might not be). Mind you, reviewing the original code suggests the whole problem can be avoided by using one of two different conversion techniques: Change [tt]ctr$ = STR$(ctr[/tt]) to [tt]ctr$ = CStr$(ctr)[/tt] or delete [tt]ctr$ = STR$(ctr)[/tt] and change [tt]a$ = a$ + "000" + ctr$[/tt] to [tt]a$ = a$ + "000" + ctr[/tt] (or, perhaps better, [tt]a$ = a$ & "000" & ctr[/tt])