|
-
Sep 28th, 2010, 03:01 AM
#1
Thread Starter
Addicted Member
-
Sep 28th, 2010, 03:45 AM
#2
Frenzied Member
Re: Text validation help
hay,
you can use RegularExpressions to do such thing
Code:
Dim numericReg As New Regex("^[\d]*$")
If numericReg.IsMatch("12345") Then
// the match done
Return True
Else
// there is no match
/// add the message that you want
Return False
End If
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
-
Sep 28th, 2010, 04:03 AM
#3
Thread Starter
Addicted Member
Re: Text validation help
Hm... Really sorry but I don't know how to implement this in my code, I didn't use this till now
-
Sep 28th, 2010, 04:11 AM
#4
Frenzied Member
Re: Text validation help
ok,
Code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
If TextBox1.Text = ("") Or TextBox2.Text = ("") Then
Label5.Text = ("Niste unjeli dva broja, pokusajte ponovo")
Else
Dim numericReg As New System.Text.RegularExpressions.Regex("^[\d]*$")
If numericReg.IsMatch(TextBox1.Text) AndAlso numericReg.IsMatch(TextBox2.Text) Then
Dim prvi As Integer = TextBox1.Text
Dim drugi As Integer = TextBox2.Text
Label5.Text = (prvi + drugi)
Else
Label5.Text = "please enter numbers"
End If
End If
End Sub
i think this will make it for you
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
-
Sep 28th, 2010, 04:13 AM
#5
Frenzied Member
Re: Text validation help
but really i don't know if this was right or not
Code:
Dim drugi As Integer = TextBox2.Text
if it was right then the code will work fine.
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
-
Sep 28th, 2010, 04:16 AM
#6
Thread Starter
Addicted Member
Re: Text validation help
Thanks so much, this works great and now I have an example, thanks!
-
Sep 28th, 2010, 04:18 AM
#7
Frenzied Member
Re: [RESOLVED] Text validation help
glad to hear this,
if you want to learn more about RegularExpressions
http://gskinner.com/RegExr/
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
-
Sep 28th, 2010, 05:05 AM
#8
Thread Starter
Addicted Member
Re: Text validation help
 Originally Posted by avrail
but really i don't know if this was right or not
Code:
Dim drugi As Integer = TextBox2.Text
if it was right then the code will work fine.
yes, it is correct because I need two numbers 
thanks for the link!
-
Sep 28th, 2010, 05:07 AM
#9
Frenzied Member
Re: [RESOLVED] Text validation help
ok, great i was just want to check if it was right or wrong
you can check if the numbers was 2 digits or not
use this
Code:
System.Text.RegularExpressions.Regex("^[\d]{2}$")
You Don't Have to Rate Me.
I'm Not a Civilized Man I'm the Civilization it self
White or Black, Living or Dieing and 0 or 1 that's MY life
iam an Object in Object Oriented Life
my blog : http://refateid.blogspot.com/
twitter : @avrail
010011000111010101110110001000000100110101111001001000000101000001100011 
-
Sep 28th, 2010, 05:23 AM
#10
Thread Starter
Addicted Member
Re: [RESOLVED] Text validation help
 Originally Posted by avrail
ok, great i was just want to check if it was right or wrong
you can check if the numbers was 2 digits or not
use this
Code:
System.Text.RegularExpressions.Regex("^[\d]{2}$")
thanks
-
Sep 28th, 2010, 07:10 AM
#11
Re: [RESOLVED] Text validation help
Hey,
You might want to think about using the built in controls for this, i.e:
http://msdn.microsoft.com/en-us/library/bwd43d0x.aspx
That way you will get validation both on the client side, and the server side.
Gary
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
|