Sorry, no. On the other hand, it would get really confusing, since VB. NET uses the same operator for both assignment and equality.
Sorry, no. On the other hand, it would get really confusing, since VB. NET uses the same operator for both assignment and equality.
If a = be Then 'wait, is this an assignment or comparison?! Instead, just set the variable and compare: Dim customer As Customer = Nothing customer = GetCustomer(id) If IsNothing(customer) Then Return False End If.
Okay, then I use this way :) – Torben Jul 28 '10 at 7:06.
No, I'm fairly sure this is not possible - but be thankful! This is a "feature" of C-based languages that I would never encourage the use of, because it is probably misused or misinterpreted more often than not. I think the best approach is to try and express "one thought per line", and resist coding that combines two operations in the same line.
Combining an assignment and a comparison in this way usually doesn't achieve much other than making the code more difficult to understand.
VB doesn't do that very well, especially since assignment and comparison both use the = operator. It'd get really confusing. And since VB to some degree is designed to be newbie-friendly (The B in "BASIC" actually stands for "Beginner's"), expressions with multiple side effects are not something the language generally likes to do.
If it's essential that you be able to do it all in one line, then you could make the GetCustomer method assign to a ByRef parameter, and return a boolean saying whether the assigned value was null. But really, it's better to just assign and then compare to null.
Thank you, so I just assign and compare :) – Torben Jul 28 '10 at 7:07.
Thinking out loud because you didn't show Customer or GetCustomer... Dim myCust As New Customer If myCust. GetCustomer(someID) Then End If Class Customer Private _customerID As Integer Const noCustomer As Integer = -1 Public Sub New() Me. _customerID = noCustomer 'no customer End Sub Public Function GetCustomer(ByVal id As Integer) As Boolean 'perform required action to get customer 'if successful then set Me.
_customerID to ID else set it to no customer value Return Me. HaveCustomer End Function Public Function HaveCustomer() As Boolean If Me. _customerID = noCustomer Then Return False Else Return True End Function End Class.
There is no builtin support for doing this, but you could use this workaround. Public Function Assign(Of T)(ByRef destination As T, ByVal value As T) As T destination = value Return destination End Function And then it could be used like this. Dim customer As Customer = Nothing If IsNothing(Assign(customer, GetCustomer(id))) Then Return False End If.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.