Re: Option Compare Statement

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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


.



Relevant Pages

  • RE: Performance Counter Errors
    ... error Health Monitor messages in server performance report. ... Data type: REG_SZ ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)
  • Re: Help me about Filter
    ... For example, the forms newsgroup covers Access forms, not ... group (data type = text) ... Set rssppd = New Recordset ... rssppd.ActiveConnection = con ...
    (microsoft.public.access.forms)
  • Re: Refactoring/Optimizing code
    ... do I get rid of the "avoid unused private fields" notification ... This is a Visual Basic newsgroup, of which VB6 is the latest version. ... In VB6 you need to specifically declare the variable type for each declaration and the above code would declare sHGBvalue as a Variant (the default data type), since its type is not specified, and sHGBdate as a string. ...
    (microsoft.public.vb.general.discussion)
  • Re: Handling Access events in .net
    ... In your first post on this topic you wrote: ... able to trigger VB code from within Access means that I can transition the ... Cindy Meister ... This reply is posted in the Newsgroup; please post any follow question or reply ...
    (microsoft.public.office.developer.automation)
  • Re: Redirection issue
    ... Ed Prochak wrote: ... of fd1 and fd2 to char and the redirection works fine now. ... your source listing from the first post is not the version of code you ... NEVER expect responses in a newsgroup in less than 24 hours. ...
    (comp.lang.c)