Re: Data String Manipulation

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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!



.



Relevant Pages

  • Re: Weird behavior from strtr function. Default behavior or bug?
    ... return value would be an empty string. ... I have a string and i want to get the first character of that string ... the matches the alphabet ... array of matching items and their indices in the string as an array. ...
    (comp.lang.php)
  • Re: LPCWSTR to CString conversion problem
    ... I get the first character of the string and pass it to ... LPCWSTR to CString conversion. ... Do you compile as Unicode or Ansi? ... GetAtreturns the second character of the string, ...
    (microsoft.public.vc.atl)
  • Re: Converting Type Characters to type string
    ... used to determine whether or not the input was a integer roman numeral ... advice and are using Get_Line to read an entire string first, ... look at the first character of the string to see whether it's Q or a ... can still convert the entire input string using Integer'Value. ...
    (comp.lang.ada)
  • RE: Help required to read and print lines based on the type of first character
    ... Please, don't top-post, and learn to quote & snip ... elif '##' in data: ... Read doc for the strip method of string ... the specification is that it should seek for the first character and based on that it should take the decision. ...
    (comp.lang.python)
  • Re: Filter
    ... other criteria that would make that first character important (like greater than ... A1 has formula =FilterCriteria(A3) with Auto filter in A3 ... Function FilterCriteriaAs String ... Is Nothing Then GoTo Finish ...
    (microsoft.public.excel.misc)