473,698 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A way to get "Like" to use "Option Compare Text" without changing the setting for all my code?

Hi,

Is there a way to do a "text" (rather than "binary") compareison with
the "like" operator, without changing the global "Option Compare"
setting? I don't want to risk breaking many, many lines of functional
code just to get one "like" operation to behave as I wish.

I want to check whether a single-character string is (a letter or
number, INCLUDING diacritical letters) or whether it is (something
else.)

if str1$ like "[A-Z]" or str1$ like "#" then
'blah blah blah
else
'blah blah blah
end if

....would work if I changed the source file's option to "text", but as I
said, I don't want to risk breaking the rest of the code. It's the need
to include diacritical letters in that makes this complicated,
otherwise I could just add an [a-z] comparison.

Is there another way to do this, or a way to make this work?

Thanks.

Nov 21 '05 #1
1 3516
In case anyone is interested / faces a similar problem, here's how I
solved it:

In the library that I use for most of my applications, I created a
"TextCompar e" class in it's own source file, which is Option Compare
Text. The class consists of public shared functions that simply invoke
the "like" operator and other comparison checks that reply on "Option
Compare".

(For my other source files, I've added an explicit "Option Compare
Binary" in addition to the obligitory "Option Strict On" and "Option
Explicit On" just so it's unambigous what's happening).

Now, if I want "Compare Binary" I do the comparison the standard way.
If I want "Compare Text" (and String.Compare( ) isn't appropriate) I
call the TextCompare static method.

=============== =============== =============== ==========

Option Strict On
Option Explicit On
Option Compare Text

Public Class TextCompare

Public Shared Function txtEquals(ByVal str1$, ByVal str2$) _
As Boolean
Return str1$.Equals(st r2$)
End Function

Public Shared Function txtLike(ByVal str1$, ByVal pattern$) _
As Boolean
If str1$ Like pattern$ Then Return True
Return False
End Function

Public Shared Function indexOf(ByVal outerStr$, ByVal innerStr$) _
As Integer
Return outerStr$.Index Of(innerStr$)
End Function

Public Shared Function lastIndexOf(ByV al outerStr$, ByVal
innerStr$) _
As Integer
Return outerStr$.LastI ndexOf(innerStr )
End Function

Public Shared Function startsWith(ByVa l outerStr$, ByVal innerStr$)
_
As Boolean
Return outerStr$.Start sWith(innerStr)
End Function

Public Shared Function endsWIth(ByVal outerStr$, ByVal innerStr$) _
As Boolean
Return outerStr$.EndsW ith(innerStr)
End Function

End Class

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2934
by: Neil Zanella | last post by:
Hello, I would like to use CSS to apply a width of 100% to all <input> elements, but to only those that have an type attribute set to "text", without affecting check boxes, radio buttons, etc... How can this be accomplished with CSS? Thanks,
2
5657
by: IkBenHet | last post by:
Hello, I am uploading a file using this form in ASP.NET. I have also added a simpel textfield: <form runat="server" enctype="multipart/form-data"> <input type="file" id="oFile" Name="oFile" size="70" runat="Server"> <input type="text" SIZE="20" MAXLENGTH="20" id="Name" NAME="Name"> <input type="submit" id="Submit" runat="Server" value="Submit" OnServerClick="SubmitButton_Click"> </form>
11
6403
by: Bruce Lawrence | last post by:
Ok, I'm baffled... I'm making a query in access 97 between 2 tables. There is a field in both tables called "DWGNO". OPENORD has a record with a DWGNO of "00000012345" DIEDATA has a record with a DWGNO of "12345" I'm not doing this with VBA right now. I'm doing it through the query gui.
2
1258
by: Alan | last post by:
Hi, IE lets the user set the "Text Size" to use when viewing pages. That sizing works fine when I view my pages directly in the IE browser, but the changes don't seem to carry over to VS 2005's design view. Instead that seems to always be set at "medium". Is there a way in Visual Studio, similar to IE's, to set the "Text Size" used in VS's design view? Thanks,
2
2263
by: alxasa | last post by:
Hello, I am hoping someone can help me with this. I need a javascript function, which sits inside a <input type="text" name="firstname"> line of code. Now, if someone starts typing fine, but when it goes 1 character past 15 characters (15 characters only allowed), in this case I would like the contents of the input to be cleared out (automatically), and reset the input and its value back to nothing. a) Can this be done, and will someone...
2
3589
by: Navodit | last post by:
Hi I am new to Javascript and am not sure what is the difference between the following two statements: <script type="text/javascript"> ..... </script>
7
2444
by: MLH | last post by:
If I drop Like "*ABC*" in a QBE grid criteria cell, the records returned include mixed case. Can I force the uppercase limitation in a QBE grid?
3
1759
by: PVACC | last post by:
I have a line of code thus: w3('<input type=radio name=rad onclick="parent.mySub('+i+')">'); The function w3() writes the code in an iframe. I need to set a variable "start" to the value "1" when a radio button is selected but BEFORE executing "parent.mySub()". Can anyone help me with the required code? Thanks
0
8685
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
9171
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
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
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
5869
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
4373
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...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
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.