This question already has answers here:
'If' statement and the colon
(5 answers)
Closed 8 years ago.
What this code mean in VB.NET ?
I don't understand with : operator.
Is it same with ternary operator in Java/C#/C ?
If InStr(elementName, "*") > 0 And depth < maxDepth Then isRule = True : isGrRule = True
In VB.NET, colon : is used to put two statements in one line and acts as a separator for those statements.
See more on MSDN:
To place multiple statements on the same line
Separate the statements with a colon (:), as in the following example.
text1.Text = "Hello" : text1.BackColor = System.Drawing.Color.Red
It has nothing to do with the ternary operator in Java/C#/C.
Related
This question already has answers here:
How do I escape a single quote in SQL Server?
(14 answers)
Closed 8 months ago.
I am using SQL Server and SSMS.
I am writing a CASE expression in SQL. Here is one of the lines
WHEN [Group] = 'Representation Accepted' AND [Reason] = 'Reduced to Warning Notice' Area Authorised' THEN 31
The issue I am having here is that for the string:
Reduced to Warning Notice' Area Authorised
SQL is getting confused with the quotation mark here and believes it to be the end of the condition and completely omits " Area Authorised". I'm not sure how to solve this issue without removing the single quotation mark. Does anyone know how I cam make SQL accept the entire string with the quotation mark as a condition?.
use two times single quotation as below
WHEN [Group] = 'Representation Accepted' AND [Reason] = 'Reduced to Warning Notice'' Area Authorised' THEN 31
This question already has answers here:
How to write ternary conditional operator?
(33 answers)
Closed 4 years ago.
What is the equivalent of this expression in Kotlin.
a ? b : c
This is giving error.
In Kotlin, if statements are expressions. So the following code is equivalent:
if (a) b else c
Hope it's working for you.
This question already has answers here:
Is there a conditional ternary operator in VB.NET?
(5 answers)
Closed 4 years ago.
In C# I can do this:
string outcome = (success?"succeeded":"failed")
But in VB.NET is this syntax the only equivalent operation?:
If (success) Then
outcome = "succeeded"
Else
outcome = "failed"
End If
outcome = If(success,"succeeded","failed")
This question already has answers here:
Boolean 'NOT' in T-SQL not working on 'bit' datatype?
(7 answers)
Closed 6 years ago.
I have a table in which I have 2 Column ID Int and IsActive Bit. I want to update bit value. If bit is true then false and if bit is flase then true.
For This I have used below query and its works fine but is there any other way to do this task.
Update Table_1 set IsActive = Case when IsActive = 0 then 1 Else 0 End
Thanks,
Hitesh Paghadal
Duplicate of Boolean 'NOT' in T-SQL not working on 'bit' datatype? which gives the answer "col = ~ col" as the XOR operator - it also illustrates every other method of doing it.
This question already has answers here:
Equals(=) vs. LIKE
(16 answers)
WHERE clause on SQL Server "Text" data type
(7 answers)
Closed 7 years ago.
what is the differences between = to like ?
thanks for help :)
by the way if it's help , the error i get is: the data types text and varchar are incompatible in the equal to operator [msg 402]
1:
Like
The LIKE operator is used to search for a specified pattern in a column.
Where
The WHERE clause is used to extract only those records that fulfill a specified criterion.
In your case the first query do not work is because no records match the criteria you are searching.