Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Field Code Function - Mid?

    Is there a Field code mid$ function?

    If not, (and I think not) is there a way to return a substring of a string in an existing field code (say, a Document variable reference)?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    JustCallMeAl
    Guest

    Re: Field Code Function - Mid?

    I would guess there isn't a mid$-type function for field codes, for the main reason is that you can have two different values within the field code: 1. The "code" language, i.e., seq, date, mergeformat, etc.; and 2. The result of the field code, i.e., April 15, 1999.

    With VBA, you can access the "code" with the code property of the fields collection and you can access the result with the result property of the fields collection.

    With those two properties, you should be able to use the mid$ function.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field Code Function - Mid?

    I make a lot of use of this. It was cleaned up during an earlier reincarnation of the lounge.

    <pre>Public Function strSplitStringAt(strIN As String, strDelim As String, boolDirection As Boolean)
    ' Procedure : strSplitStringAt
    ' Description: Return the leading or trailing portion of a string.
    ' Copyright: Chris Greaves Inc.
    ' Inputs: A string.
    ' A delimiter character.
    ' A directional flag True==>leading string
    ' Returns: A sub-string of the original string.
    ' Assumes: None.
    ' Side Effects: None.
    ' Tested: By the calls shown below.
    ' If the delimiter is found TRUE returns the first sub-string
    ' If the delimiter is found FALSE returns all but the first sub-string
    ' If the delimiter is not found TRUE returns the original string
    ' If the delimiter is not found FALSE returns the empty string
    Dim lngI As Long
    If strDelim = "" Then
    strSplitStringAt = ""
    Else
    lngI = InStr(1, strIN, Left(strDelim, 1))
    If lngI > 0 Then
    If boolDirection Then
    strSplitStringAt = Left(strIN, lngI - 1)
    Else
    strSplitStringAt = Right(strIN, Len(strIN) - lngI)
    End If
    Else
    If boolDirection Then
    strSplitStringAt = strIN
    Else
    strSplitStringAt = ""
    End If
    End If
    End If
    'Sub TESTstrSplitStringAt()
    'MsgBox strSplitStringAt("here,is,a,string", ",", True) ' "here"
    'MsgBox strSplitStringAt("here,is,a,string", ",", False) ' "is,a,string"
    'MsgBox strSplitStringAt("string", ",", True) ' "string"
    'MsgBox strSplitStringAt("string", ",", False) ' ""
    'End Sub
    End Function
    </pre>



    I also have a small set of code that mantles(!) and dismantles substrings within strings. You can ask for the 4th substring delimited by a comma, or the 3rd substring delimited by a space etc. Let me know ....

Posting Permissions

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