469,641 Members | 1,129 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

Remove Name From Text

68
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Toggle2_Click()
  2.  
  3. Dim Begining_name As Integer
  4. Dim End_name As Integer
  5. Begining_name = InStr(1, urtext, "(") + 1
  6. End_name = InStr(1, urtext, ")") - 1
  7. urtext = Mid(urtext, Begining_name, 5)
  8. End Sub
Apr 14 '09 #1
3 1147
MikeTheBike
637 Expert 512MB
@ahd2008
Hi

I don't think your code returns '294643)' ie. it's more than 5 charactures, but this should give you '294643'
Expand|Select|Wrap|Line Numbers
  1. Private Sub Toggle2_Click()
  2. Dim Begining_name As Integer
  3. Dim End_name As Integer
  4.     Begining_name = InStr(1, urtext, "(") + 1
  5.     End_name = InStr(1, urtext, ")")
  6.     urtext = Mid(urtext, Begining_name, End_name - Begining_name)
  7. End Sub

MTB
Apr 14 '09 #2
ahd2008
68
Thanks a lot. i works properly now.
Apr 14 '09 #3
NeoPa
32,203 Expert Mod 16PB
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 :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Toggle2_Click()
  2.   Me.urtext = Split(Replace(Me.urtext,")","("),"(")(1)
  3. End Sub
Apr 14 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Mikael Petterson | last post: by
2 posts views Thread by Claudio Jolowicz | last post: by
9 posts views Thread by Ken | last post: by
10 posts views Thread by Mike Copeland | last post: by
3 posts views Thread by Allen Chen [MSFT] | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.