long if

[b][red]This message was edited by liger13 at 2005-11-22 15:47:43[/red][/b][hr]
is it possible to put:

if intcom <> "a1", "b2", or "c4" then

end if

or what is a synatax that will work?


Comments

  • : [b][red]This message was edited by liger13 at 2005-11-22 15:47:43[/red][/b][hr]
    Use This Code
    if u want ur code accept atleast one condition to be true then use this
    [code]
    if intcom <> "a1" OR intcom <> "b2" OR intcom <> "c4" then
    'ur condition
    end if
    [/code]
    and if u want ur code to accept when all the conditions are true then use this
    [code]
    if intcom <> "a1" AND intcom <> "b2" AND intcom <> "c4" then
    'ur condition
    end if
    [/code]



  • [b][red]This message was edited by rlc at 2005-11-23 6:12:51[/red][/b][hr]
    Use 'OrElse' or 'AndAlso' to short circuit condition statements with reference types, funciton calls, or just for logic reasons. Not sure what exactly you are doing, but a bit mask may make your work shorter.

    ~rlc

    EDIT: Just a note you won't see much performance improvement from this change unless one condition is calling another process... But logically it improves flow and readability.
  • : [b][red]This message was edited by rlc at 2005-11-23 6:12:51[/red][/b][hr]
    : Use 'OrElse' or 'AndAlso' to short circuit condition statements with reference types, funciton calls, or just for logic reasons. Not sure what exactly you are doing, but a bit mask may make your work shorter.
    :
    : ~rlc
    :
    : EDIT: Just a note you won't see much performance improvement from this change unless one condition is calling another process... But logically it improves flow and readability.
    :

    oh ok. can you give an example im not quite sure what you are saying
  • yeah im not sure either .... wat RLC told
    please give some example
  • [code]

    if foo = value _
    or foo = value2 then
    'both statements will be evaluated even if foo = value
    end if

    if foo = value _
    OrElse foo = value2 then
    'if foo = value then foo = value2 is not evaluated
    end if

    if not bar is nothing _
    and bar.someMember = value then
    ' if bar is nothing, next condition still evaluates and causes object ref error
    end if

    'vb6 had to do nest conditions
    if not bar is nothing then
    if bar.someMember = value then

    end if
    end if

    '.net short circurit allows this
    if not bar is nothing _
    andalso bar.someMember = value then
    'if bar is nothing next statement not evaluated
    end if[/code]

    make sense?

    ~rlc
  • oh i get it. :)
  • [b][red]This message was edited by liger13 at 2005-11-23 12:55:6[/red][/b][hr]
    but i still dont see how it makes this work: (a snipit from my code)

    If KeyAscii = 97 And linkp <> "c3", "a5", and "b3" Then
    If linkx > 1 Then
    linkold = linkp
    linkx = linkx - 1
    linkp = linky & CStr(linkx)
    Call linkmove
    End If
    ' end code snipit

    or do i just have to write the whole thing out like this:

    If KeyAscii = 97 And linkp <> "c3" and linkp <> "a5" _
    and linkp <> "b3" Then 'a
    If linkx > 1 Then
    linkold = linkp
    linkx = linkx - 1
    linkp = linky & CStr(linkx)
    Call linkmove
    End If


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories