Difference between revisions of "="
From Xojo Documentation
(Changed deprecated StrComp to String.Compare.) |
|||
Line 43: | Line 43: | ||
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 [[FolderItem|FolderItems]], '''=''' determines whether they have the same reference, not whether they point to the same file. | 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 [[FolderItem|FolderItems]], '''=''' determines whether they have the same reference, not whether they point to the same file. | ||
− | Use [[ | + | Use [[String.Compare]] to do a case-sensitive [[String|string]] comparison. |
You can use [[Operator_Compare|Operator_Compare]] to define comparisons for classes. | You can use [[Operator_Compare|Operator_Compare]] to define comparisons for classes. | ||
Line 62: | Line 62: | ||
== See Also == | == See Also == | ||
− | [[Equals]], [[Greater_than|>]], [[Greater_than=|>=]], [[Less_than|<]], [[Less_than=|<=]], [[Not_equal|<>]] | + | [[Equals]], [[Greater_than|>]], [[Greater_than=|>=]], [[Less_than|<]], [[Less_than=|<=]], [[Not_equal|<>]] operators; [[Operator_Compare|Operator_Compare]], [[String.Compare]] functions; [[Operator_Precedence |Operator precedence]]. |
[[Category:Text_Strings]] | [[Category:Text_Strings]] |
Latest revision as of 14:16, 26 January 2021
The = character is to determine whether one expression is equal to another or to assign a value to a property or variable. String comparisons are case-insensitive.
Usage
result = expression1 = expression2
Part | Type | Description |
---|---|---|
result | Boolean | Returns True if expression1 is equal to expression2. |
expression1 | String, Number, Boolean, Color, or Object | Any expression. |
expression2 | String, Number, Boolean, Color or Object | Any expression. |
result=value
Part | Type | Description |
---|---|---|
result | Any | The property, variable, array, or array element that is assigned value. |
value | Any | The value assigned to result. |
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.
Use String.Compare to do a case-sensitive string comparison.
You can use Operator_Compare to define comparisons for classes.
Sample Code
The following example tests whether two strings are equal.
Var t2 As String = "There"
If t1 = t2 Then
// t1 is equal to t2
Else
// t1 is not equal to t2
End If
See Also
Equals, >, >=, <, <=, <> operators; Operator_Compare, String.Compare functions; Operator precedence.