¿Qué hacen las funciones lógicas IMP y EQV en VB6? ¿Alguien ha encontrado un uso del mundo real para ellos?

StackOverflow https://stackoverflow.com/questions/927119

  •  06-09-2019
  •  | 
  •  

Pregunta

And, Or, Xor y Not Entiendo. Lo que no obtengo son Imp y Eqv. ¿Qué quieren decir? ¿Cómo entraron allí? ¿Hay algún uso real para ellos?

¿Fue útil?

Solución

IMP es "implicación material" "A implica B" o "si A entonces B", que es equivalente a no A o B. El EQV es "equivalencia" o "si y solo si", por lo que un EQV B es lo mismo que (a Imp B) y (B Imp A).

Llegaron allí porque alguien quería estar completo. Pueden acortar algunas expresiones lógicas, pero siempre puede expresar lo mismo con no, y, no y o, o con Xor solo.

Otros consejos

Aquí está la tabla de verdad para todos los operadores, tanto para Boolean como para Bitwise. El mejor momento para usarlos es cuando asigna su lógica y se da cuenta de que tiene una función que toma dos entradas, y tiene las mismas salidas que esos operadores :)

------------------------------------------------------------------------------------------------------------------
|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  |
------------------------------------------------------------------------------------------------------------------

IIRC, they both perform a bitwise !XOR on the two inputs and return the result.

They are not present in any of the .Net code base (unless you count the VB6 compatibility layer library) so should be considered deprecated and therefor ignored.

Off the top of my head I can't say as I've ever used them.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top