When two values of the same type are distinct, one of them is usually higher than the other. VBasic provides a logical operator that allows you to find out if one of two values is greater than the other. The operator used for this operation uses the > symbol. Its syntax is: Value1 > Value2 Both operands, in this case Value1 and Value2, can be variables or the left operand can be a variable while the right operand is a constant. If the value on the left of the > operator is greater than the value on the right side or a constant, the comparison produces a True value. Otherwise, the comparison renders False or null:
Here is an example: Module Exercise Public Function Main() As Integer Dim PartTimeSalary, ContractorSalary As Double Dim IsLower As Boolean PartTimeSalary = 20.15 ContractorSalary = 22.48 IsLower = PartTimeSalary > ContractorSalary MsgBox("Part Time Salary: " & PartTimeSalary & vbCrLf & "Contractor Salary: " & ContractorSalary & vbCrLf & "Is PartTimeSalary > ContractorSalary? " & IsLower) PartTimeSalary = 25.55 ContractorSalary = 12.68 IsLower = PartTimeSalary > ContractorSalary MsgBox("Part Time Salary: " & PartTimeSalary & vbCrLf & "Contractor Salary: " & ContractorSalary & vbCrLf & "Is PartTimeSalary > ContractorSalary? " & IsLower) Return 0 End Function End Module This would produce: The greater than or the equality operators can be combined to produce an operator as follows: >=. This is the "greater than or equal to" operator. Its syntax is: Value1 >= Value2 A comparison is performed on both operands: Value1 and Value2. If the value of Value1 and that of Value2 are the same, the comparison produces a True value. If the value of the left operand is greater than that of the right operand, the comparison still produces True. If the value of the left operand is strictly less than the value of the right operand, the comparison produces a False result:
|
|
|||||||
|