473,809 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 2431
RhysW
70 New Member
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
2743
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 .StartingNumber = 1 .CountBy = 1
0
1674
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 create PDF documents using one of the components available http://www.asppdf.com but we want to do the same in Word Document. I wonder if someone can suggest some code or a component to allow us to do
0
1100
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 changed from within my access module depending on the content i'm sending to word. The document consists of a fixed header, where i put some data, but that's no problem, i've put my fields there, with bookmarks, and they get filled
4
3371
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 word-document to make a decent report (transferring a report from access to word means a lot of loss on lay out, which I find a clear showcase of microsoft's socalled software quality).
0
1403
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 word documents. (web upload, backend processing and web delivery) I spent the whole day on google to find a solution. What I am looking for is an asp script or a property that can look at a word document and just return a yes or no as to...
2
2547
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
2517
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 template. The user will then be asked whether to save as or open the word document on his client machine. Question1)Is there a way to manipulate the word document in memory
1
1533
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, Sort sort) throws IOException Problem : I cant able to search the word. If the word contain special character like , %BF It just taken that special character a empty space and search the remaining character
10
9255
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 Word.Document 'Avoid error 429, when Word isn't open. On Error Resume Next Err.Clear
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10639
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7661
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.