Reputation: 927
In C I can do this:
if(e=my_func()){
...
}
There is some equivalent in VB?
Upvotes: 0
Views: 82
Reputation: 1069
You need a function returning something. Let's say it is a boolean.
Function x() As Boolean
Return True
End Function
Now you can check it like this:
If x() = True Then
'do something
End If
or more simply:
If x() Then
'do something
End If
Here is other possibilities, just to make it clear.
Function x() As Integer
Return 5
End Function
If x() = 5 Then
'do something
End If
If Not (x() = 5) Then
'do something
End If
Dim y as Integer
y = x()
If y = 5 Then
'do something
End If
Upvotes: 0
Reputation: 43046
I believe the equivalent is this:
e = my_func()
If e Then
'...
You also have to keep in mind that VB has different rules for implicitly converting values to the Boolean type.
Upvotes: 1