Albert's token idea is close, but sometimes I see them inadvertantly place
spaces in the number.
Then just strip out the spaces before you call my routine...
strNumber = stripSpaces([yourFildName])
strNumber = ntoken(strNumber,1)
however, for a numer like
9000-638968-JKL
Do you want 9000, or do you want all numbers? 9000638968 returned?
Furhter, are some like:
9000-638968-JKL-2343
In the above, do you wnat ALL of the number, or just the first set of
numbers?
or, are there examples liek the above?
as metoend, if you write a simple routine to strip out spaces (and perhaps
hynphnes, then again, my example code should do the trick).
In fact, you might even forget my mtoek, and just pull out all number (as
long as there are no other stray numerbe liek my above last number example).
Public Function OnlyNumbers(myphone As String) As String
Dim i As Integer
Dim mych As String
OnlyNumbers = ""
If IsNull(myphone) = False Then
For i = 1 To Len(myphone)
mych = Mid$(myphone, i, 1)
If InStr("0123456789", mych) > 0 Thenf
OnlyNumbers = OnlyNumbers & mych
End If
Next i
End If
End Function
So, you can still well use the above onlynubmers idea, and/or the nToken
idea. Which of the above approach you use depends on if number ever occur
after like my last example:
9000-638968-JKL-2343
If number never occur after the first set of numbers, the simple onlynumbers
as above will do the trick.
If you need the numbers before the first string (JKL), and *somtimes*
numbers can occur after the JKL text, then I would use the stripspaces +
"-", and perhaps strip out a few others. Then throw the results to the
nToken, and pull out the first number. Easy as pie either way....