944,187 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 7212
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 15th, 2006
0

Comparison of text in textbox

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Manithan is offline Offline
4 posts
since Nov 2006
Nov 15th, 2006
0

Re: Comparison of text in textbox

Sure which part are you stuck on?
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Nov 16th, 2006
0

Re: Comparison of text in textbox

Click to Expand / Collapse  Quote originally posted by iamthwee ...
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.
Last edited by tgreer; Nov 21st, 2006 at 2:35 pm. Reason: Added code tags, removed non-code formatting.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Manithan is offline Offline
4 posts
since Nov 2006
Nov 16th, 2006
0

Re: Comparison of text in textbox

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.

Quote ...
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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Nov 16th, 2006
0

Re: Comparison of text in textbox

Click to Expand / Collapse  Quote originally posted by iamthwee ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Manithan is offline Offline
4 posts
since Nov 2006
Nov 16th, 2006
0

Re: Comparison of text in textbox

I think you want to use the equals method here to check if they are equal, that is, the same string.
Reputation Points: 45
Solved Threads: 28
Posting Whiz in Training
Dukane is offline Offline
282 posts
since Oct 2006
Nov 21st, 2006
0

Re: Comparison of text in textbox

Click to Expand / Collapse  Quote originally posted by Dukane ...
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...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Manithan is offline Offline
4 posts
since Nov 2006
Nov 21st, 2006
0

Re: Comparison of text in textbox

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

VB.NET Syntax (Toggle Plain Text)
  1. Dim var As String = "www.google.com"
  2.  
  3. Dim test As String = "www.google.com"
  4.  
  5. If test = var Then
  6. MsgBox("match")
  7. End If
  8.  
  9. Else
  10. MsgBox("wrong")
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Nov 21st, 2006
0

Re: Comparison of text in textbox

It's not working because you never check the contents of the textbox in your code.
Reputation Points: 45
Solved Threads: 28
Posting Whiz in Training
Dukane is offline Offline
282 posts
since Oct 2006
Nov 23rd, 2006
0

Re: Comparison of text in textbox

Quote ...
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.
Last edited by iamthwee; Nov 23rd, 2006 at 4:33 pm.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Filling list box with available date formats
Next Thread in VB.NET Forum Timeline: Help, Adding data into db ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC