By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,968 Members | 1,295 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,968 IT Pros & Developers. It's quick & easy.

Remove Name From Text

P: 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
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 635
@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

P: 68
Thanks a lot. i works properly now.
Apr 14 '09 #3

NeoPa
Expert Mod 15k+
P: 31,709
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.