2009-05-29 6 views
8

And, Or, Xor e Not Capisco. Quello che non ottengo sono Imp e Eqv. Cosa vogliono dire? Come ci sono entrati? C'è un vero uso per loro?Cosa fanno le funzioni logiche IMP ed EQV in VB6? Qualcuno ha trovato un uso del mondo reale per loro?

+0

Si potrebbe aggiungere qualche collegamento agli argomenti manuale di riferimento VB6 per IMP ed EQV. http://msdn.microsoft.com/en-us/library/aa242794(VS.60).aspx e http://msdn.microsoft.com/en-us/library/aa242780(VS.60).aspx – MarkJ

risposta

12

L'IMP è "implicazione materiale" "a implica b" o "se a then b", che equivale a NOT a OR b. EQV è "equivalenza" o "se e solo se", quindi un EQV b è uguale a (a IMP b) AND (b IMP a).

Sono arrivati ​​perché qualcuno voleva essere completo. Possono abbreviare alcune espressioni logiche, ma puoi sempre esprimere la stessa cosa con NOT e AND, NOT e OR oppure con XOR da solo.

+1

+1. È possibile aggiungere alcuni collegamenti agli argomenti del manuale di riferimento VB6 su IMP e EQV. http://msdn.microsoft.com/en-us/library/aa242794(VS.60).aspx e http://msdn.microsoft.com/en-us/library/aa242780(VS.60).aspx – MarkJ

+0

Potrei *, ma questo significherebbe trovarli. Ick. Grazie per averlo fatto da solo. –

+0

'EQV' non è uguale a' = '? – Roland

0

IIRC, eseguono entrambi un bit XOR bit sui due ingressi e restituiscono il risultato.

Non sono presenti in alcuno della base di codice .Net (a meno che non si contenga la libreria di livelli di compatibilità VB6), quindi dovrebbero essere considerati deprecati e quindi ignorati.

In cima alla mia testa non posso dire come mai li ho usati.

2

Ecco la tabella di verità per tutti gli operatori, sia per boolean che per bit per bit. Il momento migliore per usarli è quando si mappa la tua logica e rende conto di avere una funzione che prende due ingressi, e ha le stesse uscite quegli operatori :)

------------------------------------------------------------------------------------------------------------------ 
|AND |  |  |  |OR |  |  |  |XOR |  |  |  |IMP |  |  |  |EQV |  |  | 
------------------------------------------------------------------------------------------------------------------ 
|In1 |In2 |Out1 |  |In1 |In2 |Out1 |  |In1 |In2 |Out1 |  |In1 |In2 |Out1 |  |In1 |In2 |Out1 | 
------------------------------------------------------------------------------------------------------------------ 
|False|False|False|  |False|False|False|  |False|False|False|  |False|False|True |  |False|False|True | 
------------------------------------------------------------------------------------------------------------------ 
|False|True |False|  |False|True |True |  |False|True |True |  |False|True |True |  |False|True |False| 
------------------------------------------------------------------------------------------------------------------ 
|False|Null |False|  |False|Null |Null |  |False|Null |Null |  |False|Null |True |  |False|Null |Null | 
------------------------------------------------------------------------------------------------------------------ 
|True |False|False|  |True |False|True |  |True |False|True |  |True |False|False|  |True |False|False| 
------------------------------------------------------------------------------------------------------------------ 
|True |True |True |  |True |True |True |  |True |True |False|  |True |True |True |  |True |True |True | 
------------------------------------------------------------------------------------------------------------------ 
|True |Null |Null |  |True |Null |True |  |True |Null |Null |  |True |Null |Null |  |True |Null |Null | 
------------------------------------------------------------------------------------------------------------------ 
|Null |False|False|  |Null |False|Null |  |Null |False|Null |  |Null |False|Null |  |Null |False|Null | 
------------------------------------------------------------------------------------------------------------------ 
|Null |True |Null |  |Null |True |True |  |Null |True |Null |  |Null |True |True |  |Null |True |Null | 
------------------------------------------------------------------------------------------------------------------ 
|Null |Null |Null |  |Null |Null |Null |  |Null |Null |Null |  |Null |Null |Null |  |Null |Null |Null | 
------------------------------------------------------------------------------------------------------------------ 
|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | 
------------------------------------------------------------------------------------------------------------------ 
|In1 |In2 |Out1 |  |In1 |In2 |Out1 |  |In1 |In2 |Out1 |  |In1 |In2 |Out1 |  |In1 |In2 |Out1 | 
------------------------------------------------------------------------------------------------------------------ 
|001 |001 |001 |  |001 |001 |001 |  |001 |001 |000 |  |001 |001 |111 |  |001 |001 |111 | 
------------------------------------------------------------------------------------------------------------------ 
|001 |010 |000 |  |001 |010 |011 |  |001 |010 |011 |  |001 |010 |110 |  |001 |010 |100 | 
------------------------------------------------------------------------------------------------------------------ 
|001 |011 |001 |  |001 |011 |011 |  |001 |011 |010 |  |001 |011 |111 |  |001 |011 |101 | 
------------------------------------------------------------------------------------------------------------------ 
|001 |100 |000 |  |001 |100 |101 |  |001 |100 |101 |  |001 |100 |110 |  |001 |100 |010 | 
------------------------------------------------------------------------------------------------------------------ 
|010 |001 |000 |  |010 |001 |011 |  |010 |001 |011 |  |010 |001 |101 |  |010 |001 |100 | 
------------------------------------------------------------------------------------------------------------------ 
|010 |010 |010 |  |010 |010 |010 |  |010 |010 |000 |  |010 |010 |111 |  |010 |010 |111 | 
------------------------------------------------------------------------------------------------------------------ 
|010 |011 |010 |  |010 |011 |011 |  |010 |011 |001 |  |010 |011 |111 |  |010 |011 |110 | 
------------------------------------------------------------------------------------------------------------------ 
|010 |100 |000 |  |010 |100 |110 |  |010 |100 |110 |  |010 |100 |101 |  |010 |100 |001 | 
------------------------------------------------------------------------------------------------------------------ 
|011 |001 |001 |  |011 |001 |011 |  |011 |001 |010 |  |011 |001 |101 |  |011 |001 |101 | 
------------------------------------------------------------------------------------------------------------------ 
|011 |010 |010 |  |011 |010 |011 |  |011 |010 |001 |  |011 |010 |110 |  |011 |010 |110 | 
------------------------------------------------------------------------------------------------------------------ 
|011 |011 |011 |  |011 |011 |011 |  |011 |011 |000 |  |011 |011 |111 |  |011 |011 |111 | 
------------------------------------------------------------------------------------------------------------------ 
|011 |100 |000 |  |011 |100 |111 |  |011 |100 |111 |  |011 |100 |100 |  |011 |100 |000 | 
------------------------------------------------------------------------------------------------------------------ 
Problemi correlati