Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #2218

Re: VB6 IF OR THEN

From Deanna Earley <dee@earlsoft.co.uk>
Newsgroups comp.lang.basic.visual.misc
Subject Re: VB6 IF OR THEN
Date 2015-01-02 10:03 +0000
Organization Aioe.org NNTP Server
Message-ID <m85qh3$ckd$1@speranza.aioe.org> (permalink)
References <01a069ac-0e7d-4808-adb8-a548c348c89a@googlegroups.com>

Show all headers | View raw


On 27/12/2014 17:03, geomodelers@gmail.com wrote:
> Hi All,
>
> I am trying use operator OR but does not work. The coding below;
>
> '---------------------------------
> If Text1.Text <> "12" Or "53" Or "32" Or "63" Or "65" Then

As mentioned, each side of the Or needs to be a full valid expression, 
but even if you expanded that statement, it wouldn't work as expected.

If Text1.Text <> "12" Or Text1.Text <> "53" Or Text1.Text <> "32" Or 
Text1.Text <> "63" Or Text1.Text <> "65" Then

If you pass in 32, the expression will be:

If True Or True Or False Or True Or True Then

Which still evaluates to True.
You would need to invert the check to:

If Text1.Text <> "12" And Text1.Text <> "53" And Text1.Text <> "32" And 
Text1.Text <> "63" And Text1.Text <> "65" Then

Or:

If Not (Text1.Text = "12" Or Text1.Text = "53" Or Text1.Text = "32" Or 
Text1.Text = "63" Or Text1.Text = "65") Then

(Or remove the Not and swap the contents of the conditional blocks)

For further details, look up boolean algabra.

-- 
Deanna Earley (dee@earlsoft.co.uk, dee@doesnotcompute.co.uk)

(Replies direct to my email address will be printed, shredded then fed 
to the rats. Please reply to the group.)

Back to comp.lang.basic.visual.misc | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

VB6 IF OR THEN geomodelers@gmail.com - 2014-12-27 09:03 -0800
  Re: VB6 IF OR THEN "Mayayana" <mayayana@invalid.nospam> - 2014-12-27 12:46 -0500
    Re: VB6 IF OR THEN geomodelers@gmail.com - 2014-12-27 10:55 -0800
      Re: VB6 IF OR THEN "Mayayana" <mayayana@invalid.nospam> - 2014-12-27 17:00 -0500
  Re: VB6 IF OR THEN Deanna Earley <dee@earlsoft.co.uk> - 2015-01-02 10:03 +0000

csiph-web