-
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?
-
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]
-
Hey! kedaman, I thought you're out of the Gotham City?
-
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?
-
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.
-
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.
-
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
-
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
-
So what's the big deal with imp? What possibly could you have use for with imp, Al?
-
I give up.
Hi,
I've got a headache trying to figure out the logic.
The logical operator Imp seems to be illogical.
Al.
-
illogical?
We can use it for AI then :D
-
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
-
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.
-
It's residue from the old days :), when bit manipulation was more common.
-
=> 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
-
Has anyone heard of the PPmt function? I was looking for diffeent functions today and came across this one. It calculates interest on money.
-
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.
-
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. :D
-
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
-
Would't that be the same as:
SetAttr Files(i), GetAttr(Files(i)) OR vbReadOnly
-
-
old posts showing up again :p looking at how stupid you've been back then :o
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)
-
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
-
kedaman
you're right of course
a AND(NOT b) is somewhat clearer...
The search for a use for IMP continues......
:)