Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Position of alphabet in a alphanumeric value 1

Status
Not open for further replies.

LJS1

Programmer
Apr 29, 2002
39
0
0
US
Hi all,
How to search the position of the first alphabet in a alphanemric value.
For eg.
"12345 QRS"
I want the position of the Q , 7

I wrote the Instr function like
pos = Instr("12345 QRS","[A-Z]*")
It is not giving the result.

Thanks,
Ljs
 
You probably want something cleaner but the following may work for you:
Code:
        Dim pos As Integer
        Dim strString As String
        Dim strChar As String

        strString = "12345 QRS"
        For pos = 1 To strString.Length
            strChar = Mid(strString, pos, 1)
            If Asc(strChar) > 64 And Asc(strChar) < 123 Then
                Exit For
            End If
        Next
        Response.Write(&quot;Position: &quot; & pos)
 
Thank u very much Rich, as u said i was looking for a one line function. But your source cde worked like charm.
LJS
 
Don't forget about the System.Char class and the isLetter() method!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top