Results 1 to 24 of 24

Thread: Most useless operator in vb

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Question

    Look at this:

    0 Imp 0 = 1
    0 Imp 1 = 1
    1 Imp 0 = 0
    1 Imp 1 = 1

    What possibly could you need the imp operator for? I have never used it, never seen it used, never heared of it, don't know what it is good for, and everything else tells me Imp is the most useless operator in vb. Is it?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Question

    Imp ????

    --------------------------------------------------------

    Ahhh MSDN Definition

    Code:
    Dim A, B, C, D, MyCheck
    A = 10: B = 8: C = 6: D = Null   ' Initialize variables.
    MyCheck = A > B Imp B > C   ' Returns True.
    MyCheck = A > B Imp C > B   ' Returns False.
    MyCheck = B > A Imp C > B   ' Returns True.
    MyCheck = B > A Imp C > D   ' Returns True.
    MyCheck = C > D Imp B > A   ' Returns Null.
    MyCheck = B Imp A   ' Returns -1 (bitwise comparison).
    [Edited by r0ach on 06-09-2000 at 12:41 PM]

    r0ach™
    Don't forget to rate the post

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Hey! kedaman, I thought you're out of the Gotham City?

  4. #4

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hehe, i'll stay another week, i got phone call

    r0ach, what! i know that but can you find any practical use of it or is it just a practiacal joke?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722
    uhm, let's see...






    No. I can't think of anything.

    Sorry.

    I tried to see if it might be the opposite of another operator (like Eqv operator being opposite of Xor), but it's not.

    r0ach™
    Don't forget to rate the post

  6. #6
    Guest
    Maybe they stuck it in there for fun, or just to have more functions.

    There are a lot of functions in VB that people have never heard about.

  7. #7

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Surely it must be useful for something, or why would they have that example, i don't know why?!?!!?

    and the inverse function to imp must be not imp

    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Imp And Or Xor

    Hi,
    Well Imp is definitly related to And Or and Xor. Following is what MSDN has to say about each. Maybe someone can make sense of this.

    Sorry for the formatting. ( Or the lack thereof )

    Al.

    Imp Operator
    Used to perform a logical implication on two expressions
    Syntax
    result = expression1 Imp expression2
    The Imp operator syntax has these parts:
    Part Description
    result Required; any numeric variable
    expression1 Required; any expression.
    expression2 Required; any expression.
    Remarks
    The following table illustrates how result is determined:
    If expression1 is And expression2 is The result is
    True True True
    True False False
    True Null Null
    False True True
    False False True
    False Null True
    Null True True
    Null False Null
    Null Null Null
    The Imp operator performs a bitwise comparison of identically positioned bits in two numeric expressions
    and sets the corresponding bit in result according to the following table:
    If bit in expression1 is And bit in expression2 is The result is
    0 0 1
    0 1 1
    1 0 0
    1 1 1

    And Operator
    Used to perform a logical conjunction on two expressions
    Syntax
    result = expression1 And expression2
    The And operator syntax has these parts:
    Part Description
    result Required; any numeric variable
    expression1 Required; any expression.
    expression2 Required; any expression.
    Remarks
    If both expressions evaluate to True, result is True. If either expression evaluates to False, result is False.
    The following table illustrates how result is determined:
    If expression1 is And expression2 is The result is
    True True True
    True False False
    True Null Null
    False True False
    False False False
    False Null False
    Null True Null
    Null False False
    Null Null Null
    The And operator also performs a bitwise comparisonof identically positioned bits in two numeric expressions
    and sets the corresponding bit in result according to the following table:
    If bit in expression1 is And bit in expression2 is The result is
    0 0 0
    0 1 0
    1 0 0
    1 1 1

    Or Operator
    Used to perform a logical disjunction on two expressions
    Syntax
    result = expression1 Or expression2
    The Or operator syntax has these parts:
    Part Description
    result Required; any numeric variable
    expression1 Required; any expression.
    expression2 Required; any expression.
    Remarks
    If either or both expressions evaluate to True, result is True. The following table illustrates how result is determined:
    If expression1 is And expression2 is Then result is
    True True True
    True False True
    True Null True
    False True True
    False False False
    False Null Null
    Null True True
    Null False Null
    Null Null Null
    The Or operator also performs a bitwise comparisonof identically positioned bits in two numeric expressions
    and sets the corresponding bit in result according to the following table:
    If bit in expression1 is And bit in expression2 is Then result is
    0 0 0
    0 1 1
    1 0 1
    1 1 1

    Xor Operator
    Used to perform a logical exclusion on two expressions
    Syntax
    [result =] expression1 Xor expression2
    The Xor operator syntax has these parts:
    Part Description
    result Optional; any numeric variable
    expression1 Required; any expression.
    expression2 Required; any expression.
    Remarks
    If one, and only one, of the expressions evaluates to True, result is True. However, if either expression is Null
    result is also Null. When neither expression is Null, result is determined according to the following table:
    If expression1 is And expression2 is Then result is
    True True False
    True False True
    False True True
    False False False
    The Xor operator performs as both a logical and bitwise operator. A bit-wise comparison
    of two expressions using exclusive-or logic to form the result, as shown in the following table:
    If bit in expression1 is And bit in expression2 is Then result is
    0 0 0
    0 1 1
    1 0 1
    1 1 0
    A computer is a tool, not a toy.

  9. #9

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    So what's the big deal with imp? What possibly could you have use for with imp, Al?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    I give up.

    Hi,

    I've got a headache trying to figure out the logic.
    The logical operator Imp seems to be illogical.

    Al.
    A computer is a tool, not a toy.

  11. #11
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    illogical?

    We can use it for AI then

  12. #12
    Junior Member
    Join Date
    Dec 1999
    Posts
    25

    Cool

    it looks familar. The imp operator is use to see if 2 variables are the same. the operators And, Or, and Xor are used to restrict the statement. If u only use the imp operator then what it does is check to see if the statements are the same or different. Using the other operators changes the value u recieve. Example: Either both values must be true or one of the 2 values must be true. with the Or and Xor operators it works this way. I am not sure what way it actually is, but anyway here it goes.

    with one operator the first variable stated must be true and the second one false. with the other operator it is the exact reverse. the first one must be false and the second one must be true.

    Now the logical purpose for these operators is in some financial program or one where the difference between given variables is extremely important.

    I remember most of this from a critical thinking class i took couple semesters back. the true/false table with the information reminded me of all this

  13. #13
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    it's the same as the => operator in maths, it's pronounced "implies", a => b means that if a is true then b is true, which gives us the results you are getting. I suspect it's used for completeness, if you add it to the And Or and Xor operators then take 2 boolean values.

    a and b

    there are 4 possible sets of results

    1 a is true b is true
    2 a is false b is true
    3 a is true b is false
    4 a is false b is false


    now if we divide these up into 2 catagoried eg
    1&2, 3&4 or 3,1&2&4 there are 16 ways of doing this.

    for any way of dividing them up we can have a simple statement
    Code:
    If a X b Then
    
        Call Firstfunc
    
    Else
    
        Call SecondFunc
    
    End If
    where X is one of the four bitwise operators sutch that if the state of the variables is one catacory it calls firstfunc if it's in the other catagory calls secondfunc
    (you may have to switch the functions around or just have a or True or something insted of a X b)

    as for uses it has uses but if you're not used to using it it could be easier just to use Not (a And (Not b)) or ((Not a) Or b) instead. but Imp would be slightly faster.

  14. #14
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    It's residue from the old days , when bit manipulation was more common.



  15. #15

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    => argh! <= How can you more dumb than that, it's in the name, implies. Thanks Sam, but i think it's still a bit useless since i have never thought of having use of => in vb
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  16. #16
    Guest
    Has anyone heard of the PPmt function? I was looking for diffeent functions today and came across this one. It calculates interest on money.

  17. #17

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well i'm not interested in money, ok of course i am, but not interested in interests, there are a bunch of those functions: DDB,Ipmt,IRR,MIRR,NPer,NPV,Pmt,PPmt,PV,Rate,SLN,SYD, so i don't know, I have never used those.

    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  18. #18
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Lightbulb Finance?

    If it is financial functions thou art seeking, enter thy code window, and typeth - Financial. (with the period), and thou shall get thy list.

    If you just want to compose poems with too much thy in them, though, choose a different forum.

  19. #19
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    GOT IT!!

    I've found a used for imp!!!!

    I frequently have to set files to writable in Windows Explorer (you know, right-click properties etc. ) so I thought that if I wrote a small app which reads the file name from the command line I could put a short-cut to it in "send to"
    it would speed thing up a bit.


    I don't want to do SetAttr Filename,vbNormal because I want to leave all other attribute in place eg, hidden etc.

    So, to set a file as writable I need to clear BIT 1 if set and leave it clear if not set.

    so here it is:

    Code:
    Option Explicit
    
    Sub Main()
    Dim Files() As String
    Dim i As Integer
    Files = Split(Command(), " ")
    For i = 0 To UBound(Files()) 
      
      SetAttr Files(i), Not (GetAttr(Files(i)) Imp vbReadOnly)
    Next i
    
    End Sub
    Mark
    -------------------

  20. #20
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Would't that be the same as:


    SetAttr Files(i), GetAttr(Files(i)) OR vbReadOnly

  21. #21
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    try it Frans C
    Mark
    -------------------

  22. #22

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    old posts showing up again looking at how stupid you've been back then

    The definitions of implication i found in my papers:

    p imp q = (p or q = q)
    p imp q = not(p) or q
    p imp q = p and q = p

    btw mark,
    not(a imp b)
    is the same as
    a and not(b)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  23. #23
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Oops, I missed a bracket.
    I misread:
    SetAttr Files(i), Not (GetAttr(Files(i)) Imp vbReadOnly)
    for:
    SetAttr Files(i), Not (GetAttr(Files(i))) Imp vbReadOnly

  24. #24
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    kedaman

    you're right of course

    a AND(NOT b) is somewhat clearer...


    The search for a use for IMP continues......

    Mark
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width