Results 1 to 4 of 4
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Devide string.... (2000)

    I have this 2 line in text file:

    8505-500-0000000080-14079060 74178
    8505-1700-00000000E0-12855388 76177

    i know:

    8505 is fixed for all line
    00000000E0 or 0000000080 have always the same lenght

    i want to get 500 and 1700

    but i canot use the fixed lenght because 500 is 3 digit and 1700 is 4 digit o to get it...?

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Devide string.... (2000)

    If the value is in A1:
    =MID(A1,FIND("-",A1)+1,FIND("-",A1,FIND("-",A1)+1)-FIND("-",A1)-1)

    Steve

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Devide string.... (2000)

    If you want a function ot use in VB:

    <pre>Option Explicit
    Function ExtractMe(str As String)
    Dim iFirst As Integer
    Dim iSecond As Integer
    iFirst = InStr(str, "-")
    iSecond = InStr(iFirst + 1, str, "-")
    ExtractMe = Mid(str, iFirst + 1, iSecond - iFirst - 1)
    End Function</pre>


    Steve

  4. #4
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Devide string.... (2000)

    If the information between the dashes (-) is always a number, you could also use:

    Function sal1(str As String) As String
    sal1 = CStr(Val(Mid(str, InStr(str, "-") + 1, 99)))
    End Function

Posting Permissions

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