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

Member Avatar for iamthwee

Sure which part are you stuck on?

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.

Member Avatar for 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.

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.

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

Member Avatar for Dukane

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

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...

Member Avatar for iamthwee

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")
Member Avatar for Dukane

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

Member Avatar for iamthwee

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.

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

hello dear's...
plz clear my doubt in vb.net...

consider 2 textbox.first one is for holding a simple statement.second one is for holding paragraph.if a particular word exist in both the textboxes means ,it need to prompt an error(don't forget the second textbox contains paragraph)

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim aWord As String = "Hello"
    If TextBox1.Text.Contains(aWord) Or TextBox2.Text.Contains(aWord) Then
        MessageBox.Show("The word '" & aWord & "' has been found in any of the textboxes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End If
End Sub

the word is case sensitive, besides this is a 5 Years old thread, you could of have made a new thread instead of bumping this one

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.