Difference between revisions of "Not equal"
From Xojo Documentation
m |
|||
Line 46: | Line 46: | ||
<rbcode> | <rbcode> | ||
− | + | Var t1 As String = "Hello" | |
− | + | Var t2 As String = "There" | |
If t1 <> t2 Then | If t1 <> t2 Then | ||
Line 58: | Line 58: | ||
Test that an object is not Nil before it is used: | Test that an object is not Nil before it is used: | ||
<rbcode> | <rbcode> | ||
− | + | Var d As New Dictionary | |
If d <> Nil Then | If d <> Nil Then | ||
d.Value("Test") = "Hello" | d.Value("Test") = "Hello" |
Latest revision as of 19:40, 22 November 2019
Used to determine whether one expression is not equal to another. String comparisons are case-insensitive.
Usage
result = expression1 <> expression2
Part | Type | Description |
---|---|---|
result | Boolean | Returns True if expression1 is not equal to expression2. |
expression1 | String, Number, Object, Color, or Date | Any expression. |
expression2 | String, Number, Object, Color, or Date | Any expression. |
Notes
The data types of expression1 and expression2 must match. You can make comparisons between objects of any data type and between objects. If you compare objects, <> compares their references, not their contents. For example, when you compare two FolderItems, <> determines whether they have the same reference, not whether they point to the same file.
The <> operator is also used with objects to test whether they are Nil. For example, when you use the MemoryBlock constructor to create a new object, test whether the new object is Nil before proceeding.
Use StrComp to do a case-sensitive string comparison.
You can use Operator_Compare to define comparisons for classes.
Sample Code
Check if two string values are different:
Var t2 As String = "There"
If t1 <> t2 Then
// t1 is not equal to t2
Else
// t1 is equal to t2
End If
Test that an object is not Nil before it is used:
See Also
>, >=, <, <=, =, and StrComp operators; Operator_Compare function; Operator precedence.