1

I have a GPS station feature dataset and I need to label using field NAME. However, I need to label only the number, for example in the field NAME the name are GPS123, STATION 239, STN 325 but the label need only appear 123,239 and 325. I already tried using this VB script expression but its not work properly.

Function FindLabel ([NAME])
  FindLabel = [NAME]
  FindLabel=mid(FindLabel,4)
End Function
2
  • Is it always three digits, and always last in your string? If so, you can use that as base to split the string and/or only display those three characters.
    – Martin
    Nov 3, 2014 at 8:07
  • hi martin.. no, some data are 2 digits and some are 4 digits, and the number always last in string.
    – user
    Nov 3, 2014 at 8:18

1 Answer 1

2

You can achieve this with a regular expression. The current logic below assumes the format is as described above, i.e. 1 or more numbers in a single group at the end of the string. So it will not find numbers embedded in the string "bob123gps456".

Function FindLabel ( [FeatureClassName]  )
  dim s, reg, mc
  s =  [FeatureClassName]
  set reg = new RegExp
  reg.IgnoreCase =True
  reg.Global = False
  reg.Pattern = "\d+$"
  set  mc = reg.Execute(s)
  if mc.count = 0 then
    FindLabel = "no number"
  else
    findLabel = mc.Item(0)
  end if
End Function
1
  • Hi Hornbydd... i already try it and its work...tq so much..
    – user
    Nov 4, 2014 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.