Re: Option Compare Statement
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Tue, 23 Sep 2008 17:57:23 -0400
"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: Bob
- Re: Option Compare Statement
- References:
- Option Compare Statement
- From: Bob
- Option Compare Statement
- Prev by Date: Re: Arrays
- Next by Date: Re: VB 2005 versions
- Previous by thread: Re: Option Compare Statement
- Next by thread: Re: Option Compare Statement
- Index(es):
Relevant Pages
|