For some time I have been pondering how one particular line of some code works (contributed some time ago by our beloved guru strongm).
This is used to check if a computer is connected to your network (pinging) and works very well.
The line in my question is "IsReachable = objStatus.StatusCode = 0" where you have 2 equals sign in the one statement.
So it seems the code line is equivalent to
If objStatus.StatusCode = 0 then
IsReachable = True
Else
IsReachable = False
End IF
Similarly
a=0=0: print a gives true
a=1=0: print a gives true
I would be grateful for an explanation on how the 2 equal signs work to create a boolean result to put me out of my misery!
This is used to check if a computer is connected to your network (pinging) and works very well.
Code:
If strComputer > "" Then
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objPing = objWMIService.ExecQuery("Select * From Win32_PingStatus
Where Address = '" & strComputer & "' and StatusCode=0")
'pings computer
For Each objStatus In objPing
IsReachable = objStatus.StatusCode = 0
Next
End If
(IsReachable = True if computer is connected)
So it seems the code line is equivalent to
If objStatus.StatusCode = 0 then
IsReachable = True
Else
IsReachable = False
End IF
Similarly
a=0=0: print a gives true
a=1=0: print a gives true
I would be grateful for an explanation on how the 2 equal signs work to create a boolean result to put me out of my misery!