954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Comparison of text in textbox

Hi im doing a application tool which will check for spoof email headers. now i want to do some comparison of text in textbox

can anyone help me in this?

thank you

Manithan
Newbie Poster
4 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

Sure which part are you stuck on?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
Sure which part are you stuck on?



HI thanks for ure reply

Im stuck on the comparison part

From: ""
Received:""

Dim Text1 AsString = "Received:"""
Dim Text2 As String = "From:"""

If String.Compare(Text1, Text2, True) = 1 Then
MsgBox("Genuine Email")
End If
If String.Compare(Text1, Text2, False) = 0 Then
MsgBox("Spoofed Email")
End If
If TextBox2.Text = "" Then
MessageBox.Show("You must enter something in the text box")
End If


I did this but it is not working...it doesnt comparing..coz if the from and received from is same then its genuine else it is spoofed...

Can you help me on this?

Thanks.

Manithan
Newbie Poster
4 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

Are you sure your compare method is correct?

For example if both strings are identical is the value equal to 1, like you have put or is it equal to 0.

I think it is equal to 0.

Comparing Strings The Compare method compares two strings and returns an integer value. The return value of Compare method can be less than zero, greater than zero or equals to zero.

Value Meaning Less than zero When first string is less than second. Zero When both strings are equal. Greater than zero When first string is greater than zero.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
Are you sure your compare method is correct? For example if both strings are identical is the value equal to 1, like you have put or is it equal to 0. I think it is equal to 0.



Can u show me the codes for it?

Thank u

Manithan
Newbie Poster
4 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

I think you want to use the equals method here to check if they are equal, that is, the same string.

Dukane
Posting Whiz in Training
295 posts since Oct 2006
Reputation Points: 45
Solved Threads: 29
 
I think you want to use the equals method here to check if they are equal, that is, the same string.



Hi

Can u show me the codes for it ???i still trying but its not wokin coz once i click the button it not comparing the text in the textbox...

Manithan
Newbie Poster
4 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

I honestly can't see how you don't understand this?

Dim var As String = "www.google.com"

Dim test As String = "www.google.com"

If test = var Then
  MsgBox("match")
End If

Else
  MsgBox("wrong")
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

It's not working because you never check the contents of the textbox in your code.

Dukane
Posting Whiz in Training
295 posts since Oct 2006
Reputation Points: 45
Solved Threads: 29
 

Dim var As String = "www.google.com"

Dim test As String = "www.google.com"

If test = var Then MsgBox("match") End If

Else MsgBox("wrong")

Hi Thanx for ure code...but this not the code that im sayin abt....act i dunnoe to compare a string within a string eg:From:"BOB" and Received:"Lisa" have to compare that both from a chunk of email headers from the microsoft outlook..coz im doin a application tool to detect for spoofed email..so i have to compare the 2 field from:"" & received:"" field....if "BOB" and "LISA" r the same den its genuine email else its spoofed....its like compare string within string...i hope u get wad i mean here...thank u very much....it will b a great help if u can help me on dis....

You say you don't know how to compare a string within a string.

You need to google 'searching for substrings within a string'. I know vb.net has a method for this.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

Dim Domain as string = @Yahoo.com

private sub CheckIfEmailsHaveSameDomain(Email1 as string,Email2 as string)

if email1.indexof(domain) >= 1 then
msgbox(" First Email From Yahoo")
else
msgbox("First Email Not From Yahoo")
end if
if email2.indexof(domain) >= 1 then
msgbox(" Second Email From Yahoo")
else
msgbox(" Second Email Not From Yahoo")
end if
If you want another word change domain to something else

Cammarata123
Newbie Poster
9 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 

lavada la vundi

saivisweswar
Newbie Poster
1 post since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You