Re: Data String Manipulation
- From: dymondjack <dymondjack at hot mail dot com>
- Date: Tue, 24 Feb 2009 06:52:05 -0800
How about something like this
Function MakeString(Scan As String) As String
Dim Ret As String
'Get rid of the first character
Ret = Mid(Scan, 2, Len(Ret) - 1)
'Check 1st Number for 0
If Mid(Ret, 1, 1) = "0" Then
Ret = Mid(Ret, 2, Len(Ret) - 1)
GoTo Exit_Func
End If
'Check 6th Number
If Mid(Ret, 6, 1) = "0" Then
Ret = Mid(Ret, 1, 5) & Mid(Ret, 6, Len(Ret) - 6)
Goto Exit_Func
End If
'Check 10th Number
If Mid(Ret, 10, 1) = "0" Then
Ret = Mid(Ret, 1, 9) & Mid(Ret, 11, Len(Ret) - 11)
End If
Exit_Func:
MakeString = Ret
Exit Function
End Function
I haven't tried the function, you may have to adjust the Len() subtraction
numbers, but this should get you pretty close.
hth
--
Jack Leach
www.tristatemachine.com
- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
"Jerry" wrote:
Thanks, using the Mid function gets me started. It gets very complicated! I.
always need to delete the first character in the scanned string, then Check
the 1st number in the string - if it is 0, remove it to get the 10 digit NDC
·If the 1st number is not a zero, check the 6th - if it is 0, remove it to
get the 10 digit NDC
·If neither the 1st nor the 6th digits are 0, check the 10th digit - if it
is 0, remove it to get the 10 digit NDC
·If a 0 is not the 1st, the 6th, or the 10th character in the string, it is
an invalid 11 digit NDC
Hopefully that makes it a little clearer.
Thanks
"Douglas J. Steele" wrote:
Not sure I really follow, but you'd use the Mid function to look at specific
positions.
Mid([MyString], 1, 1) will give you the content of the first position,
Mid([MyString], 6, 1) will give you the content of the sixth position,
Mid([MyString], 10, 1) will give you the content of the tenth position and
so on.
You can also use the Mid function to remove the first character:
Mid([MyString], 2) will return everything from position 2 on.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Jerry" <Jerry@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:79F0D63B-5527-4F71-A21C-17512333A242@xxxxxxxxxxxxxxxx
I have a filed on a form that a barcode is being scanned into. The raw
scan
contains characters I need to remove. I always need to remove the first
character, then I have to check the first, 6th and tenth sopt for 0 and
remove the first one, then stop. I then have a query that searches a
table
for the string. Can this be done in Access? I am guessing it may involve
the instr function in some way, but I am just not sure.
Thanks for any input!
- Follow-Ups:
- Re: Data String Manipulation
- From: Jerry
- Re: Data String Manipulation
- References:
- Data String Manipulation
- From: Jerry
- Re: Data String Manipulation
- From: Douglas J. Steele
- Re: Data String Manipulation
- From: Jerry
- Data String Manipulation
- Prev by Date: Re: Return a value from a form opened as acDialog
- Next by Date: Re: Dynamically changing a report's recordsource property
- Previous by thread: Re: Data String Manipulation
- Next by thread: Re: Data String Manipulation
- Index(es):
Relevant Pages
|