Re: Option Compare Statement
- From: "Bob" <someonw@xxxxxx>
- Date: Wed, 24 Sep 2008 13:45:43 -0700
As always, thanks Mike. My arrays are always either double, or strings, and
both arrays are always the same type. I guess, one thing I can do, which is
the easiest (but not the cleanest code) is to have the exact routines in two
different modules, one with option compare binary, and one with option
compare text, (of course with two different names). Then depending on the
user's choice, call the appropriate routine. This way, I do not have to
mess with my code.
Bob
"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:O%231$cdcHJHA.4232@xxxxxxxxxxxxxxxxxxxxxxx
"Bob" <someonw@xxxxxx> wrote in message
news:ejRt79OHJHA.4884@xxxxxxxxxxxxxxxxxxxxxxx
Hi Everyone:
I had posted this message in another newgroup, and it was suggested that
I post it here. So, sorry about the double posting.
Your first post regarding this in the vb.controls newsgroup was,
technically, off-topic because your question has nothing to do with
controls. But it was hardly the most off-topic question posted to any of
these newsgroups. vb.general.discussion gets the most traffic. So, it's
usually the best choice. You might *cross-post* your message to other
newsgroups too (on MS's newserver; personally, I hate it when people
crosspost to non-MS newsgroups) if your question fits that particular
newsgroup as well. For example, if your question had been about a control
array, it'd have been perfectly appropriate in the vb.controls newsgroup.
In VB 6.0, I have two variant arrays, that may either contain doubles or
strings, let's say A and B. Then I want to compare their values. For
example,
If A(i)<B(i) then
c=c+1
else
c=c+2
endif
Now, on my form, I have a checkbox that asks the user if they want the
comparison to be case sensitive. So, here is my question.
1- Can I somehow achieve this by using the Option Compare. remember, the
user chooses the type of comparison.
2- if not, is the Instr statement my only option? If so, how do I handle
doubles? Do, I have to check the data type for all members, if they are
all doubles choose <. otherwise choose Instr? Or is there a better way
of doing this.
Are both arrays always going to be of the same data type? I mean, one's
not going to be of type Double and the other String, right? They're either
both going to be Double or both going to be String?
Also, be aware that comparing Doubles is not always so straight-forward
due to innaccuracies of representing a Double. If you're doing
calculations prior to the comparison, you could end up with something like
comparing 1.00000001 to 1.0 (where the expection might be 1.0 compared to
1.0...or equality)
--
Mike
Microsoft MVP Visual Basic
.
- Follow-Ups:
- Re: Option Compare Statement
- From: MikeD
- Re: Option Compare Statement
- References:
- Option Compare Statement
- From: Bob
- Re: Option Compare Statement
- From: MikeD
- Option Compare Statement
- Prev by Date: Re: Dang Vista! Help Please
- Next by Date: Re: Dang Vista! Help Please
- Previous by thread: Re: Option Compare Statement
- Next by thread: Re: Option Compare Statement
- Index(es):
Relevant Pages
|