Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
| Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2007, 11:47 PM
Authorized User
 
Join Date: Dec 2006
Location: , , Singapore.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Comparing and highlighting text !!!!!!!!!!

Hi everyone...

i have to load 2 different text(paragraph) from database to a control(panel or label).Then i shud compare and highlight the similar words in the two controls which is loaded.

please suggest me...how to do it...which control shud i use for loading text.How do i compare and highlight the similar words with colors????

please give a idea on this....this comparison shud be done in webpage.

Thanks in advance....

Karthik
[Nothing is impossible]
__________________
Karthik
[Nothing is impossible]
 
Old December 17th, 2007, 10:31 PM
Registered User
 
Join Date: Dec 2007
Location: Gulf Breeze, FL, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Seems fairly easy enough. Really depends on how you want to highlight the output text.

I'd use Scalars to get the two values:

Dim SQLConn as SQLConnection, Text1 as string, Text2 as string
Dim SQLGet as SQLCommand
SQLConn = New SqlConnection("Server=<insert server>;Database=<insert Dbase>;Integrated Security=SSPI;MultipleActiveResultSets=True")
        SQLConn.Open()
        SQLInsert = New SqlCommand("SELECT field1 FROM someTable", SQLConn)
        Text1 = SQLInsert.ExecuteScalar
SQLInsert = New SqlCommand("SELECT field2 FROM someTable", SQLConn)
        Text2 = SQLInsert.ExecuteScalar
        SQLConn.Close()

Now your variables Text1 and Text2 have the two fields.

Then, I'd Dim out a couple of string arrays, split on the space to pull back individual words and loop though them

Dim strText1() as string, strText2() as string
strText1 = Text1.Split(" ")
strText2 = text2.split(" ")

For X as integer = Lbound(strText1) to Ubound(strText1)
if strText1(x) = strText2(x) then
Console.WriteLine(strText1(x) & " matched")
else
Console.WriteLine(strText1(x) & " did not match")
end if
Next


Making it highlight from there would be easy enough.



--Ryan Campbell
ryan@extremewebguy.com
 
Old December 18th, 2007, 07:28 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

If you are going to high light similar words in colors then you are going to have to use the RichTextBox control, as its the only built in control that can have different colored text in the same box.

And it greatly depends on what you mean by 'similar words' as to how you would do the second part. An example of some input paragraphs and expected outputs would help.

/- Sam Judson : Wrox Technical Editor -/




Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with highlighting text in a combo box Kabel69 Access 5 October 18th, 2006 08:51 AM
highlighting the word in rich text box AnurRS C# 0 May 31st, 2006 06:41 AM
highlighting the text after searching shazia1 VS.NET 2002/2003 0 April 1st, 2006 04:37 PM
comparing Two text files rajkumar007 Classic ASP Basics 0 October 15th, 2005 07:22 AM
Comparing Two Text Files rajkumar007 Classic ASP Professional 0 October 14th, 2005 10:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.