Thanh Posted January 6, 2006 Posted January 6, 2006 Thanks for all the help. This is a great forums. When I scan a part number it sometimes come up with 1Pxxxxxxxxx, the rest of characters real part number. The real part number can have 8 - 10 characters. How can I remove the first 2 characters (1P) if they exixt? Again Thanks!
mr_vodka Posted January 6, 2006 Posted January 6, 2006 Well you can use the left, right, position functions but maybe you should supply us with more information so that we can help you in greater detail. Is there always 2 characters in the beginning that you want to get rid of? If so is the second character always a Alpha-character? etc etc. The more detail the better.
Thanh Posted January 6, 2006 Author Posted January 6, 2006 Here's some examples: 1PP1234LPMM - will need to trim the starting 1P 1PM123456PMM9 - will need to trim the starting 1P M123456PMM9 - No need to do any trim P12345 - No need to do any trim Thanks
mr_vodka Posted January 6, 2006 Posted January 6, 2006 Ok... so how does one determine if something needs to be trimmed or not? You still have not answered my earlier questions. We would need the rule to determine if it needs to be trimmed or not, otherwise how can we know when to trim it or not? Does it need to be trimmed only when it starts with 1P ?
Ted S Posted January 6, 2006 Posted January 6, 2006 Should work... unless the character sequence "1P" occurs elsewhere in the string and truly belongs there.
LaRetta Posted January 6, 2006 Posted January 6, 2006 (edited) It seems pretty clear that 1P should only be removed if it exists as the first two characters. In which case, Lee, your calc would also remove 1P if it exists later in the string. This should protect from that possibility ... If ( Left ( PartNumber ; 2 ) = "1P" ; Substitute ( PartNumber ; Left ( PartNumber ; 2 ) ; "" ) ; PartNumber ) LaRetta :wink2: Edited January 6, 2006 by Guest Corrected for vs. 7
Lee Smith Posted January 6, 2006 Posted January 6, 2006 Darn, I missed that it was for v7, I responded to his profile of v6. Yes, Ted, I'm aware of that too. so now, Thanh has a couple of choices. Lee
LaRetta Posted January 6, 2006 Posted January 6, 2006 (edited) Darn is right, Lee. I saw version 6!! Change the commas to semi-colons for vs. 7. Update: I corrected the above calc Edited January 6, 2006 by Guest Added Update
comment Posted January 6, 2006 Posted January 6, 2006 I'm afraid your calc suffers from the same flaw as Lee's: If ( Left ( PartNumber ; 2 ) = "1P" ; Substitute ( PartNumber ; Left ( PartNumber ; 2 ) ; "" ) ; PartNumber ) If the test is true, the substitution part evaluates as: Substitute ( PartNumber ; "1P ; "" ) Suppose the PartNumber is entered as "1P55AA1P". Your result will be "55AA", instead of "55AA1P". Try: Case ( Left ( PartNumber ; 2 ) = "1P" ; Right ( PartNumber ; Length ( PartNumber ) - 2 ) ; PartNumber )
LaRetta Posted January 6, 2006 Posted January 6, 2006 Thank you for catching it. I missed that logic about Substitute(). :wink2:
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now