473,756 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking for Alpha

How do I check to see if my textbox has a alpha character in it?

I don't want alpha characters, numeric only.

Thanks

Dooglo

Nov 21 '05 #1
8 1681
Dooglo,

What is alpha in this case, latin alphabeth 26 characters like in the
english/dutch and maybe somemore languages or more characters?

Cor
Nov 21 '05 #2
Here is one way using a reqex expression:

Private Sub txtMyTextbox_Va lidating(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles txtMyTextbox.Va lidating
Validate_txtMyT extbox()
End Sub

Private Sub Validate_txtMyT extbox()
If txtUsedYTD.Text = String.Empty Then
ErrorProvider1. SetError(txtMyT extbox, "Required")
_error = True
ElseIf Not IsNumeric(txtMy Textbox.Text) Then
ErrorProvider1. SetError(txtMyT extbox, "Not valid")
_error = True
Else
' is it really a number?

Dim rNumber As New
System.Text.Reg ularExpressions .Regex("(^\d*\. ?\d*[0-9]+\d*$)|(^[0-9]+\d*\.\d
*$)")
If rNumber.IsMatch (txtMyTextbox.T ext) Then
ErrorProvider1. SetError(txtMyT extbox, "")
Else
ErrorProvider1. SetError(txtMyT extbox, "Not valid")
_error = True
End If
End If
End Sub

HTH,
Greg

"Dooglo" <Do****@discuss ions.microsoft. com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
How do I check to see if my textbox has a alpha character in it?

I don't want alpha characters, numeric only.

Thanks

Dooglo

Nov 21 '05 #3
Hi Doogle,

You can check it while the user types it:

Private Sub TextBox1_TextCh anged(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles TextBox1.TextCh anged

If Char.IsLetter(C Char(TextBox1.T ext)) = True Then

End If

End Sub

-or chec
http://msdn.microsoft.com/library/de...ettertopic.asp
/Henrik

"Dooglo" wrote:
How do I check to see if my textbox has a alpha character in it?

I don't want alpha characters, numeric only.

Thanks

Dooglo

Nov 21 '05 #4
VJ
If you meant, I need only 0-9 and no other characters... you can use Regular
Expressions..

Imports System.Text.Reg ularExpressions

Private Function ValidateString( ByVal strText as string) as boolean

Dim retVal as boolean

retVal = RegEx.IsMatch(s trText,"[0-9]")

return retVal

End Function

For more regEx expressions see... www.regexlib.com

VJ

"Dooglo" <Do****@discuss ions.microsoft. com> wrote in message
news:81******** *************** ***********@mic rosoft.com...
How do I check to see if my textbox has a alpha character in it?

I don't want alpha characters, numeric only.

Thanks

Dooglo

Nov 21 '05 #5
* =?Utf-8?B?RG9vZ2xv?= <Do****@discuss ions.microsoft. com> scripsit:
How do I check to see if my textbox has a alpha character in it?

I don't want alpha characters, numeric only.


I would not prevent the user from entering these characters, instead I
would validate input in the textbox's 'Validating' event and make the
user aware of malformed input using an error provider. For example:

\\\
Private Sub TextBox1_Valida ting( _
ByVal sender As Object, _
ByVal e As CancelEventArgs _
) Handles TextBox1.Valida ting
Dim SourceControl As TextBox = DirectCast(send er, TextBox)
Try
Dim i As Integer = Integer.Parse(S ourceControl.Te xt)
If Me.ErrorProvide r1.GetError(Sou rceControl).Len gth > 0 Then
Me.ErrorProvide r1.SetError(Sou rceControl, "")
End If
Catch ex As Exception
Me.ErrorProvide r1.SetError( _
SourceControl, "Value must be an integer." & ex.Message & ")" _
)
End Try
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #6
Misreaded,

So because everybody who visitst this newsgroup have to give a solution
\\\only figures limited to 10 as plus as well as minus is possible as well
as exponents

Private Sub Form1_Load(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.TextBox1.Max Length = 10
End Sub
Private Sub textbox1_KeyUp( ByVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) Handles textbox1.KeyUp
If e.KeyValue <> 8 Then
If Not IsNumeric(TextB ox1.Text) Then
If TextBox1.Text.L ength > 0 Then
MessageBox.Show ("Only numeric is allowed")

TextBox1.Select ionStart = TextBox1.Text.L ength - 1
TextBox1.Select ionLength = 1
End If

End If
End If
End Sub
Private Sub TextBox1_Valida ting(ByVal sender _
As Object, ByVal e As System.Componen tModel.CancelEv entArgs) _
Handles TextBox1.Valida ting
If TextBox1.Text.L ength > 0 Then
If Not IsNumeric(TextB ox1.Text) Then
MessageBox.Show ("There was an error pasting")
TextBox1.Focus( )
e.Cancel = True
End If
End If
End Sub
I hope this helps a little bit?

Cor
Nov 21 '05 #7
Dooglo,

Forgot this question. I was to much looking at the subject

Cor
Nov 21 '05 #8
Thanks everyone for replying.

All examples are great!

"Dooglo" wrote:
How do I check to see if my textbox has a alpha character in it?

I don't want alpha characters, numeric only.

Thanks

Dooglo

Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2216
by: Abby Lee | last post by:
{ if (str.length != 3) return false; else if (str.charAt(0) != ) return false; else if (!Is_Digit(str.charAt(1))) return false; else if (!Is_Digit(str.charAt(2))) return false; else return true;
12
2312
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type text,text,radio,checkbox and select. When I run the following code, it correctly reports "text" (for input
9
4523
by: Marek Kurowski | last post by:
Yo! What mean when program is ALPHA or BETA version? I suppose it is not release version of program, but I don't know what it exactly mean. What it mean in your opinion? Marek Kurowski
3
17390
by: instruo | last post by:
I'm using the System.Drawing.Bitmap class for loading a 32-bit bmp file which includes an alpha channel. The problem is, when it gets loaded (just using the Bitmap(string filename) constructor), it doesn't bother bringing the alpha along with it. All of the pixels just show "255" as their alpha value and Bitmap.IsAlphaPixelFormat() returns false. I know that the alpha does exist physically and has worked with this exact image in other...
1
4288
by: RicercatoreSbadato | last post by:
I have notice that my images have the value Image.Flags = 2 (HasAlpha). How Can I set the Flags to 1? I would like to eliminate the alpha channel... -- RicercatoreSbadato
6
6354
by: TJO | last post by:
Below is some sample code that fades div tags that is not working in IE 6.0.29 on xp sp2. Can anyone help see why the if(ie5) document.getElementById(divID).filters.alpha.opacity lines are not working ? I cannot find a solution yet. THanks <script type="text/javascript" language=javascript> var ie5 = (document.all && document.getElementById); var ns6 = (!document.all && document.getElementById);
0
1020
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the first alpha release of Python 2.5. This is an *alpha* release of Python 2.5, and is the *first* alpha release. As such, it is not suitable for a production environment. It is being released to solicit feedback and hopefully discover bugs, as well as allowing you to determine how changes in 2.5 might impact you. If you find things broken or...
6
3655
by: tommaso.gastaldi | last post by:
In a previous post I have been asking about a way to test Alpha Transparency. Bob and Michael have kindly provided some ideas. Here I would like to share the function I have prepared, for the purpose to improve it. Frankly, I am not clear about the exact meaning of some pixel format (max, gdi, etc.) and I hope I have put them under the right "case". I have made only some superficial test and it seems to work. Note that the purpose is...
3
3625
by: Gernot Frisch | last post by:
Hi, I have this code that blends 2 pixels, but it's not really fast. Can someone help me speeding it up? #define GETR(a) (unsigned char)(((((a)>>11)&31)*255)/31) #define GETG(a) (unsigned char)(((((a)>5)&63)*255)/63) #define GETB(a) (unsigned char)(((((a) )&31)*255)/31)
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.