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. 1 3486
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
"TextCompare" 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(str2$)
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$.IndexOf(innerStr$)
End Function
Public Shared Function lastIndexOf(ByVal outerStr$, ByVal
innerStr$) _
As Integer
Return outerStr$.LastIndexOf(innerStr)
End Function
Public Shared Function startsWith(ByVal outerStr$, ByVal innerStr$)
_
As Boolean
Return outerStr$.StartsWith(innerStr)
End Function
Public Shared Function endsWIth(ByVal outerStr$, ByVal innerStr$) _
As Boolean
Return outerStr$.EndsWith(innerStr)
End Function
End Class This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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......
|
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"...
|
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...
|
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...
|
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...
|
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>
|
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?
|
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"...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |