Results 1 to 5 of 5

Thread: alphabet

  1. #1

    Thread Starter
    Hyperactive Member fasi's Avatar
    Join Date
    Nov 2000
    Posts
    474

    alphabet

    just wondering if 'isalpha' a valid VB function or not . IF not then how can i determine if the a character input is an alphabet

  2. #2
    Addicted Member Merlin's Avatar
    Join Date
    Dec 2000
    Location
    Eau Claire, WI
    Posts
    233
    'IsAlpha' is not a valid VB function. You could try IsNumeric to determine if the string is a number or if it is a valid string. I am not aware of anything intrinsic to VB that will tell you if only the characters in a string are A-Z. You could write your own function to tell if you didn't want other characters (e.g. -,`,~,=,etc...) in the string. Otherwise if you don't care about the other characters just check to see if it is numeric:
    VB Code:
    1. If IsNumeric(Text1.Text) = False then
    2.     msgbox Text1.Text
    3. End If
    poooof

    Wizard Since 1997
    SQL Server 7.0:2K, Oracle, VB 6.0 EE, VBScript, C/C++, COBOL, RPG ILE, HTML, XML, Perl

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    No it's not, but you can write your own
    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    
        If IsAlpha(KeyAscii) Then
            MsgBox "alpha"
        End If
    
    End Sub
    
    
    
    Public Function IsAlpha(intKey As Integer) As Boolean
    
        If (intKey > 96 And intKey < 123) Or _
           (intKey > 64 And intKey < 91) Then
            IsAlpha = True
        End If
    
    End Function

  4. #4
    New Member
    Join Date
    Mar 2011
    Posts
    1

    Re: alphabet

    Quote Originally Posted by MartinLiss View Post
    No it's not, but you can write your own
    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    
        If IsAlpha(KeyAscii) Then
            MsgBox "alpha"
        End If
    
    End Sub
    
    
    
    Public Function IsAlpha(intKey As Integer) As Boolean
    
        If (intKey > 96 And intKey < 123) Or _
           (intKey > 64 And intKey < 91) Then
            IsAlpha = True
        End If
    
    End Function
    bro your code is good but the only problem is the input stays in the textbox example i input letter "a" even if i added text3.text="" after the msgbox it wont clear the textbox.the letter "a" remains there.Help me plss.
    it looks like this:
    Public Function IsAlpha(intKey As Integer) As Boolean

    If (intKey > 96 And intKey < 123) Or _
    (intKey > 64 And intKey < 91) Then
    IsAlpha = True
    End If

    End Function

    Private Sub Text1_KeyPress(KeyAscii As Integer)

    If IsAlpha(KeyAscii) Then
    MsgBox "Enter Numbers Only"
    Text1.Text = ""
    End If

  5. #5
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    Re: alphabet

    You can use the KeyDown event and set the parameter to 0 if its not allowed.
    VB6 Library

    If I helped you then please help me and rate my post!
    If you solved your problem, then please mark the post resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width