468,556 Members | 2,009 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,556 developers. It's quick & easy.

Removing X number of characters starting at begining or end

Eh, probably not the most specific subject line...

But, I've got a number of fields in which I need to do things like remove
the first 4 characters, or remove the last 3.

Such as:

F300006745

Remove first 4 to leave

006745

or remove the last 3 to leave

F3000067

Is there a generic type script I can use to accomplish both of these by
changing a few parameters? Or would it require 2 distinctly seperate ones
for each operation?

Thanks.
Nov 13 '05 #1
4 59515
To remove first 4 characters:
Mid([MyField],5,Len([MyField]))

To exclude the last 3 characters:
Mid([MyField],1,Len([MyField])-3))

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Adam" <ad**@firstmanmedia.com> wrote in message
news:95*******************@204.127.204.17...
Eh, probably not the most specific subject line...

But, I've got a number of fields in which I need to do things like remove
the first 4 characters, or remove the last 3.

Such as:

F300006745

Remove first 4 to leave

006745

or remove the last 3 to leave

F3000067

Is there a generic type script I can use to accomplish both of these by
changing a few parameters? Or would it require 2 distinctly seperate ones
for each operation?

Thanks.

Nov 13 '05 #2
Adam wrote:
Eh, probably not the most specific subject line...

But, I've got a number of fields in which I need to do things like remove
the first 4 characters, or remove the last 3.

Such as:

F300006745

Remove first 4 to leave

006745

or remove the last 3 to leave

F3000067

Is there a generic type script I can use to accomplish both of these by
changing a few parameters? Or would it require 2 distinctly seperate ones
for each operation?

Thanks.


Two distinct are Left() and Right() but you'll probably get away with
just the one, mid()

Remove first 4:
NewString = Right(OldString,Len(OldString)-4)
or
NewString = Mid(OldString,5)

Remove last 4
NewString = Left(OldString,Len(OldString)-4)
or
NewString = Mid(OldString,1,Len(OldString)-4)

--
This sig left intentionally blank
Nov 13 '05 #3
Great!

One more real quick.

How about to remove everything in the string except X number of characters
starting at position Y. For example, to keep only the 3 characters
starting at position 8?

So this:

F1053630203XL1

Becomes

020

Thanks!

no****@nospam.spam (PC Datasheet) wrote in
<tX******************@newsread2.news.atl.earthlink .net>:
To remove first 4 characters:
Mid([MyField],5,Len([MyField]))

To exclude the last 3 characters:
Mid([MyField],1,Len([MyField])-3))

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Adam" <ad**@firstmanmedia.com> wrote in message
news:95*******************@204.127.204.17...
Eh, probably not the most specific subject line...

But, I've got a number of fields in which I need to do things like
remove the first 4 characters, or remove the last 3.

Such as:

F300006745

Remove first 4 to leave

006745

or remove the last 3 to leave

F3000067

Is there a generic type script I can use to accomplish both of these
by changing a few parameters? Or would it require 2 distinctly
seperate ones for each operation?

Thanks.



Nov 13 '05 #4
Ooops, never mind:

Mid([fieldname],8,3)

ad**@firstmanmedia.com (Adam) wrote in
<95*******************@204.127.199.17>:
Great!

One more real quick.

How about to remove everything in the string except X number of
characters starting at position Y. For example, to keep only the 3
characters starting at position 8?

So this:

F1053630203XL1

Becomes

020

Thanks!
F3000067

Is there a generic type script I can use to accomplish both of these
by changing a few parameters? Or would it require 2 distinctly
seperate ones for each operation?

Thanks.




Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Amit Varia | last post: by
3 posts views Thread by mr_burns | last post: by
2 posts views Thread by matt | last post: by
1 post views Thread by Phil Amey | last post: by
reply views Thread by David Lambert | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.