|
-
Oct 15th, 2003, 10:32 PM
#1
Thread Starter
Lively Member
How to check for character?
Hello, i need to check the character whcich the user input. For eg: I got email add, then need them to enter the full address of the email, then i need to check where the @ sign exists.
So how do i check? Can pls give mi some codes, i need this urgently. Thanks all the kind souls out there, hav a nice day...
-
Oct 16th, 2003, 02:27 AM
#2
you mean this? ...
VB Code:
[COLOR=blue]If Not[/COLOR] TextBox1.Text.IndexOf("@") = -1 [COLOR=blue]Then[/color]
[COLOR=blue]Dim[/color] x [COLOR=blue]As Integer[/color] = TextBox1.Text.IndexOf("@")
MessageBox.Show("the textbox contains the @ sign at char posistion : " & x)
[COLOR=blue]End If[/color]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Oct 16th, 2003, 03:13 AM
#3
Thread Starter
Lively Member
Sorrie, no, i mean is i need to check whether the user enter email add in the text box got the @ sign anot. If not, then need to prompt them error, if got, then save into the database.
-
Oct 16th, 2003, 04:38 AM
#4
the above code does check to see if there's an @ symbol , all you need is to make it suit your needs , eg:
VB Code:
[color=blue]If Not[/color] TextBox1.Text.IndexOf("@") = -1 [color=blue]Then[/color] [color=green]'/// if the string contains the @ symbol[/color]
[color=green]'/// carry out your code for the string because it contains an email address.[/color]
[color=blue]Else[/color] [color=green]'/// if it doesn't contain the @ symbol...[/color]
MessageBox.Show("you did not type a valid email address, please try again!")
[color=blue]End If[/color]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Oct 16th, 2003, 04:44 AM
#5
Thread Starter
Lively Member
Oh, it works. Thanks a lot.
So how about checking for like not more than 1 @ sign?
Then how to check e email should be .com/.gov/.edu... etc behind?
-
Oct 16th, 2003, 06:23 AM
#6
like this then ...
VB Code:
[COLOR=BLUE]If[/COLOR] [COLOR=BLUE]Not[/COLOR] TextBox1.Text.IndexOf("@") = -1 [COLOR=BLUE]Then
[/COLOR] [COLOR=BLUE]Dim[/COLOR] x [COLOR=BLUE]As[/COLOR] [COLOR=BLUE]Integer[/COLOR] = [color=black]UBound[/color](TextBox1.Text.[color=black]Split[/color]("@"c))
[COLOR=BLUE]If[/COLOR] x = 1 [COLOR=BLUE]Then
[/COLOR] [COLOR=BLUE]If[/COLOR] TextBox1.Text.EndsWith(".com".ToLower) [COLOR=BLUE]Or[/COLOR] TextBox1.Text.EndsWith(".net".ToLower) [COLOR=BLUE]Or[/COLOR] TextBox1.Text.EndsWith(".gov".ToLower) [COLOR=BLUE]Then
[/COLOR] [COLOR=GREEN]'/// it ends with .com or .net or .gov ( etc... depending what you want to look for at the end of the address )
[/COLOR] [COLOR=GREEN]'/// do your stuff here because it's a valid address...
[/COLOR] [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]If
[/COLOR] [COLOR=BLUE]Else
[/COLOR] [COLOR=GREEN]'/// it's got more than 1 @ symbol.
[/COLOR] MessageBox.Show("to many @ symbols in the address!")
[COLOR=BLUE]End[/COLOR] [COLOR=BLUE]If
[/COLOR] [COLOR=BLUE]Else
[/COLOR] MessageBox.Show("Oops that's not a valid email address!")
[COLOR=BLUE]End[/COLOR] [COLOR=BLUE]If[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
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
|