One variable which could be 'true' and 'false' at the same time?

D

Dave Neve

Hi

The folowing bit of code taken from a help page surprised me and I need to
do some ground work.

I was surprised that MyCheck could be used twice as the results could have
conceivably been 'true' and 'false' (not the case here).

How is this possible or is it bad practice and to be avoided?

Thanks in advance

Sub ArrayOrNot()
Dim MyArray(1 To 5) As Integer, YourArray, MyCheck ' Déclaration des
variables.
YourArray = Array(1, 2, 3) ' Utilisation de la fonction Array.
MyCheck = IsArray(MyArray) ' Renvoie True.
MyCheck = IsArray(YourArray) ' Renvoie True.
MsgBox (MyCheck)

End Sub
 
A

Alex Ivanov

It does not make sense having two consecutive assignments to the same
variable, however it would be perfectly fine if you check the value of
MyCheck between them and make corresponding choices.

'First check
MyCheck = IsArray(MyArray) ' Renvoie True.
If MyCheck Then
'Do something
End IF
'Another check
MyCheck = IsArray(YourArray) ' Renvoie True.
If MyCheck Then
'Do something else
End IF
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Dave Neve > écrivait :
In this message, < Dave Neve > wrote:

|| Next week I'm gonna get myself a brain!!!
||

Why wait 'til next week? ;-)
<g, d & r>

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
 
Top