Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Continued from thread 595987 MID command not worki (2003)

    Hi,

    This thread is a continuation from thread 595987.

    I require assistance with the Mid command as not all data is being imported.
    It is currently working so that data is imported from one file but not from others. The line of coding l am using is:

    sPart = VBA.Mid(sInput, iPos + 1, 8)

    Current output:
    ===============
    de013947

    Expected output:
    ================
    denc2249
    denc0010
    de013947
    atnco001
    atnc0117
    atnc0101


    See attached dbase + test files.

    Regards
    Justin

  2. #2
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Cincinnati, Ohio, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Continued from thread 595987 MID command not worki (2003)

    In continuation from the other thread.

    The function in question is IsLegalPart

    The function correctly parses only the vts4.txt file, and not the others.

    Let us try a slightly different approach.

    The function currently is passed sInput by value, which means that any changes we make to this string does not affect the string outside of this function. In other words we are passed a copy of the string. Whatever we do to the string has no effect on the original. We also pass sPart (also a string) by reference. Any change we make to sPart affects this string outside of this function.

    I want to find the first occurrence of a space in sPart. I am going to throw away everything up to and including the space. I am then going to look for the next space. All text leading up to the "second" space is considered a potential part number. If the part number is not equal to eight characters, I dismiss the part number and move on.

    Clear?

    <pre> Case "vts"
    iPos = VBA.InStr(sInput, " ")
    if iPos then
    sInput = VBA.Mid(sInput, iPos+1) 'Throw away everything up to and including the first space
    iPos = VBA.InStr(sInput, " ") 'Look for the next space
    if iPos = REQ_VTS_LEN+1 Then
    sPart = VBA.Left(sInput, REQ_VTS_LEN)
    bResult = True
    End If
    End if
    </pre>


  3. #3
    4 Star Lounger
    Join Date
    Jul 2006
    Posts
    531
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Continued from thread 595987 MID command not worki (2003)

    Hi,

    I have now managed to resolve the problem, thanks for your advice and help it is much appreciated.
    I took your thread and also got some help from a VBA delveoper, thanks once again.

    Justin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •