Place a boolean function in an if expression

I support the VB6 application. For Boolean functions, the original authors store the return value in a boolean before checking the result in the If expression. I prefer to place the function directly in the If statement. Is this a matter of preference or am I missing a potential trap in my style?

Original style of the author

bReturn = IsThisFun(maintainingVb6)
If bReturn = True Then
    'You haven't used .NET
Else
    'blah
End If

My style

If IsThisFun(maintainingVb6) Then
    'You haven't used .NET
Else
    'blah
End If

I am not sure if there is a suitable terminology for these different approaches that may have allowed me to skip the previous entry in this thread.

thank

+3
source share
7 answers

, . , 98% .

+7

, , . 2 bReturn, . If/EndIf, .

, DOK. . , , , ​​, .

+5

, .

: . , , , . ( , , = True, .)

, If Then , , , .

+3

(w/ wo/variable). , VB Boolean (OLE VARIANTBOOL), C bool . ​​ VB6, , ...

Declares ( API) , bool, As Boolean . VB , "True" ( POV), : VB 16- Boolean, 1 -1.

, If Not MyFunction(), (Not 1) -2 (Not -1) 0, . , Not(True) = True

Declare "bool" As Long CBool() .

+2

. . .

+1

, bool?

:

public bool maintainingVB6()
{
  return true;
}
0

. var , On Error Resume Next.

IsThisFun , bReturn . . , IsThisFun , If true.

"-" :

On Error Resume Next
...
If Not IsThisFun(maintainingVb6) Then
Else
    ...
End If
0

Source: https://habr.com/ru/post/1753777/


All Articles