|
-
Jun 27th, 2001, 11:22 AM
#1
Thread Starter
Hyperactive Member
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
-
Jun 27th, 2001, 11:30 AM
#2
Addicted Member
'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:
If IsNumeric(Text1.Text) = False then
msgbox Text1.Text
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
-
Jun 27th, 2001, 11:38 AM
#3
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
-
Mar 3rd, 2011, 06:03 AM
#4
New Member
Re: alphabet
 Originally Posted by MartinLiss
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
-
Mar 3rd, 2011, 08:34 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|