borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (Populate Range using VBA) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : IF ALPHABETIC test
Poster Message
pavane
Level: VB Lord

Registered: 26-04-2004
Posts: 181

icon IF ALPHABETIC test

I need to test a character for being alphabetic. It would be easy except  that I have to allow all accented characters as well, so a lookup list is not practicable.

Does anyone know of a function or API call which would do the job?

13-06-2008 at 09:15 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 537
icon Re: IF ALPHABETIC test

Paste this in a new module and try :

Option Explicit
Public Declare Function IsCharAlpha Lib "user32" Alias "IsCharAlphaA" (ByVal cChar As Byte) As Long

Public Function Alphabetic(strIN As String) As Boolean
Dim bIN As Byte
Dim blReturn As Boolean

bIN = CByte(Asc(Left$(strIN, 1)))

If IsCharAlpha(bIN) = 0 Then
blReturn = False
Else
blReturn = True
End If

Alphabetic = blReturn

End Function

Private Sub testfn()
MsgBox Alphabetic("*")

End Sub

Put your cursor in the testfn sub and hit F5 to test


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

08-07-2008 at 02:00 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : IF ALPHABETIC test
Next Topic (Populate Range using VBA) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder