Ejercicio
Función IsAlphabetic
Objetivo
Cree una función que indique si un carácter es alfabético (de la A a la Z) o no. Debe usarse así:
if (IsAlphabetic ("a"))
System.Console.WriteLine ("Es un carácter alfabético");
(Nota: no te preocupes por los acentos y ñ)
Código
Imports System
Public Class exercise123
Public Shared Function IsAlpha(ByVal simbolo As Char) As Boolean
If (simbolo >= "a"c) AndAlso (simbolo <= "z"c) Then Return True
If (simbolo >= "A"c) AndAlso (simbolo <= "Z"c) Then Return True
Return False
End Function
Public Shared Function IsAlpha2(ByVal simbolo As Char) As Boolean
simbolo = Char.ToLower(simbolo)
If (simbolo >= "a"c) AndAlso (simbolo <= "z"c) Then Return True
Return False
End Function
Public Shared Function IsAlpha3(ByVal simbolo As Char) As Boolean
simbolo = simbolo.ToString().ToLower()(0)
If (simbolo >= "a"c) AndAlso (simbolo <= "z"c) Then Return True
Return False
End Function
Public Shared Function IsAlpha4(ByVal simbolo As Char) As Boolean
Dim validas As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqwrstuvwxyz"
If validas.Contains(simbolo) Then Return True
Return False
End Function
Public Shared Sub Main()
Console.WriteLine(IsAlpha("w"c))
Console.WriteLine(IsAlpha("2"c))
End Sub
End Class