Remove Name From Text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahd2008
    New Member
    • Nov 2008
    • 68

    Remove Name From Text

    HI,

    I created the code below to remove name from tex. For instance, a field contains Caffery(294643)

    so i want to get rid of Caffery and get only the figures, but the problme that the code gives this result:
    294643)

    can anyone help to fixt it becasue i need only the figures.

    Code:
    Private Sub Toggle2_Click()
    
    Dim Begining_name As Integer
    Dim End_name As Integer
    Begining_name = InStr(1, urtext, "(") + 1
    End_name = InStr(1, urtext, ")") - 1
    urtext = Mid(urtext, Begining_name, 5)
    End Sub
    Last edited by Stewart Ross; Apr 14 '09, 10:53 AM. Reason: replaced quote tags with code tags around the code segment - please use the tags provided
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Originally posted by ahd2008
    HI,

    I created the code below to remove name from tex. For instance, a field contains Caffery(294643)

    so i want to get rid of Caffery and get only the figures, but the problme that the code gives this result:
    294643)

    can anyone help to fixt it becasue i need only the figures.

    Code:
    Private Sub Toggle2_Click()
    
    Dim Begining_name As Integer
    Dim End_name As Integer
    Begining_name = InStr(1, urtext, "(") + 1
    End_name = InStr(1, urtext, ")") - 1
    urtext = Mid(urtext, Begining_name, 5)
    End Sub
    Hi

    I don't think your code returns '294643)' ie. it's more than 5 charactures, but this should give you '294643'
    Code:
    Private Sub Toggle2_Click()
    Dim Begining_name As Integer
    Dim End_name As Integer
        Begining_name = InStr(1, urtext, "(") + 1
        End_name = InStr(1, urtext, ")")
        urtext = Mid(urtext, Begining_name, End_name - Begining_name)
    End Sub

    MTB

    Comment

    • ahd2008
      New Member
      • Nov 2008
      • 68

      #3
      Thanks a lot. i works properly now.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        The following code uses the Replace() & Split() functions.
        Replace the ")" with another "(", then Split out the elements and select the second one (1) as the returned value :
        Code:
        Private Sub Toggle2_Click()
          Me.urtext = Split(Replace(Me.urtext,")","("),"(")(1)
        End Sub

        Comment

        Working...