How can I check if a string only contains letters?

后端 未结 4 1743
耶瑟儿~
耶瑟儿~ 2020-12-06 17:52

I\'m using a function that allows me to review a string of text and evaluate if it is composed of letters. It is housed in a module called \"General\". The general module

4条回答
  •  Happy的楠姐
    2020-12-06 18:13

    Try this for IsAlpha

    Public Function IsAlpha(strValue As String) As Boolean
    Dim intPos As Integer
    
        For intPos = 1 To Len(strValue)
            Select Case Asc(Mid(strValue, intPos, 1))
                Case 65 To 90, 97 To 122
                    IsAlpha = True
                Case Else
                    IsAlpha = False
                    Exit For
            End Select
        Next
    End Function
    

提交回复
热议问题