Microsoft Office Forums


Reply
Thread Tools Display Modes

Function to look for alpha character

 
 
CPK
Guest
Posts: n/a
 
      02-23-2006, 08:57 PM
Is there a function to tell me the position of ANY alpha character in a
String ?

"123456A555"

I would expect 7 to be returned.


What I really need is a way to strip everything to the left of the A, but
the Alpha character can be A to Z and I don't want to write 26
Instr([field],Letter) If thens.

"1234B777" I need "1234"

"1234567X88" I need "1234567" etc.


thanks


 
Reply With Quote
 
 
 
 
Brendan Reynolds
Guest
Posts: n/a
 
      02-23-2006, 09:27 PM
This example is case-insensitive and will not match accented characters etc.
You can add additional characters to the constant if required.

Public Function PosFirstAlpha(ByVal StringToSearch As String) As Long

Dim lngLoop As Long
Const strcChars As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

For lngLoop = 1 To Len(StringToSearch)
If InStr(1, strcChars, _
UCase$(Mid$(StringToSearch, lngLoop, 1))) <> 0 Then
PosFirstAlpha = lngLoop
Exit For
End If
Next lngLoop

End Function


--
Brendan Reynolds
Access MVP


"CPK" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there a function to tell me the position of ANY alpha character in a
> String ?
>
> "123456A555"
>
> I would expect 7 to be returned.
>
>
> What I really need is a way to strip everything to the left of the A, but
> the Alpha character can be A to Z and I don't want to write 26
> Instr([field],Letter) If thens.
>
> "1234B777" I need "1234"
>
> "1234567X88" I need "1234567" etc.
>
>
> thanks
>



 
Reply With Quote
 
RoyVidar
Guest
Posts: n/a
 
      02-23-2006, 09:41 PM
CPK wrote in message <(E-Mail Removed)> :
> Is there a function to tell me the position of ANY alpha character in a
> String ?
>
> "123456A555"
>
> I would expect 7 to be returned.
>
>
> What I really need is a way to strip everything to the left of the A, but the
> Alpha character can be A to Z and I don't want to write 26
> Instr([field],Letter) If thens.
>
> "1234B777" I need "1234"
>
> "1234567X88" I need "1234567" etc.
>
>
> thanks


Try issuing the Val function on your data

Val("1234B777")
Val("1234567X88")

--
Roy-Vidar


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
animating text so it reveal character by character - right to left a1speaker@netscape.net PowerPoint Newsgroup 3 04-13-2006 08:01 PM
how do I set up wbs number sequence that contains alpha character. cpmp322 Project Newsgroup 1 12-23-2005 06:42 PM
WBS - Roman Numerals, Alpha characters, number, alpha Paul Project Newsgroup 1 05-10-2005 09:02 PM
Ø character display as ? character in table Tan KP Access Newsgroup 1 11-13-2003 02:30 PM
slight space between 1st character and 2nd character jna Publisher Newsgroup 2 08-07-2003 12:00 AM



All times are GMT. The time now is 08:07 PM.
Microsoft Office Forums is not affiliated with Microsoft Corporation.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92