473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

How to compare 2 strings in a word document (with special character)?

2
I need to compare two strings in a word document i work it out for alphabetic and numeric values but it is not able to compare a string which contains some special characters like (Máceres-Cartínez) Here a and i is occur with special character so it is not compare.
Apr 4 '12 #1
1 2411
RhysW
70
presumeably you want it to be able to compare them where there it would treat the á as an a and the í as an i? if so then when you bring it in you could store the sent string as a value then run it through a method where it replaces the special characters with what you want it to be treated as e.g turn all á into a, run the compare script on the filtered and changed string then return the original string before it was edited, the user never needs to know it was changed to represent a-z characters and it would never be saved or displayed back as those! hope this is a viable solution for you!

Expand|Select|Wrap|Line Numbers
  1. str.Replace('á','a');
  2. //where str is the name of the string
  3.  
for example the following code takes whatever is in a textbox, turns all á into a then pastes it back to the textbox,

Expand|Select|Wrap|Line Numbers
  1. textBox1.Text = (textBox1.Text.Replace('á', 'a'));
but you would want to do something like this i guess
Expand|Select|Wrap|Line Numbers
  1. buttonclick event
  2. {
  3. string original1 = textbox1.text;
  4. string original2 = textbox2.text;
  5. string replaced1 = original1.Replace('á', 'a'));
  6. string replaced2 = original2.Replace('á', 'a'));
  7. int comparer = Compare(replaced1,replaced2);
  8. if (comparer==1)
  9. {
  10. messagebox.show(original1);
  11. }
  12. else if (comparer == -1)
  13. {
  14. messagebox.show(original2);
  15. }
  16. else
  17. {
  18. messagebox.show("Both are equal");
  19. }
  20. }
  21. public int Compare (string a,string b)
  22. {
  23. int result = replaced1.CompareTo(replaced2);
  24. //this is 0 if they are the same
  25. //or it is -1 if replaced 1 is 'smaller'
  26. //or is 1 is replaced1 is 'bigger'
  27. return result;
  28. }
  29.  
  30.  
this isnt identical to what you asked for but should explain it well enough for you to use it as you need it!
Apr 13 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Achille | last post by:
Hi, I must insert Line Numbering (line Numbers) in word Document with script perl. The source code of the macro is: With ActiveDocument.PageSetup With .LineNumbering .Active = True...
0
by: JP SIngh | last post by:
Hi All Is it possible to create a simple word document using ASP and also set its footer to the record id and save the created document on the server. We have an ASP application and we can...
0
by: Mr. T. | last post by:
Hi, i've got a word-template based on which i make a word-document throught automatisation from within my access vba-module. So far, no problem. Now the lay-out of the document needs to be...
4
by: svdh2 | last post by:
Dear All, I have lately strugled more and more with Access, what started as a simple database has brought me to the fundaments of Access. I need to transfer fields from various tables to a...
0
by: vanwout | last post by:
Hello, An ASP page on my IIS server converts an uploaded word document to HTML, but I'm having a problem with it failing (hanging and popup requesting password on server!) on password protected...
2
by: Geoffrey | last post by:
Hello, Is it possible to have a constant String initialised with special character like that = (Char)0x02 + "CMD" + (Char)0x03 ? Thx
2
by: aychai | last post by:
Hi all, I have a scenario where users fills in textbox fields on ASP.NET page from the server and when he/she clicks on a download button, the data from fields will insert into an existing word...
1
by: Ragavendran | last post by:
Hi, I am using this method for search: Query =org.apache.lucene.queryParser.QueryParser.parse(String arg0) throws ParseException Hits = org.apache.lucene.search.Searcher.search(Query query,...
10
by: mlevit | last post by:
Hi, I've found a tutorial that shows you how to fill in Word documents with values from Access 'Print customer slip for current customer. Dim appWord As Word.Application Dim doc As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.