Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can refer to <a href="http://msdn.microsoft.com/en-us/library/office/aa188509(v=office.10).aspx" rel="nofollow">Comparing Strings by Using Comparison Operators</a></p> <p>According to this for your string comparison <code>at &lt; b</code>, the ASCII value of first character <code>1</code> is <code>49</code> and same for <code>at</code> and <code>b</code>, however the for the second character the ASCII value of <code>2</code> is more than the ASCII value of <code>1</code>, hence the expression <code>at &lt; b</code> return <code>false</code></p> <p>Also as explained in greater detail in <a href="http://msdn.microsoft.com/en-us/library/cey92b0t.aspx" rel="nofollow">Comparison Operators (Visual Basic)</a>, if you defined the primitive types of the variables the behavior get changed, see below</p> <p><b>Case-1: </b></p> <pre><code>Sub CompareNumberAndText() Dim at As String, b As String, c As String, an As Integer at = "120" an = 2 b = "1" c = "3" ct = at &lt; b 'false cn = an &lt; b 'false kl = an &lt; c 'true End Sub </code></pre> <p><b>Case-2: </b></p> <pre><code>Sub CompareNumberAndText() Dim at As String, b As String, an As Integer at = "120" an = 2 b = "1a" ct = at &lt; b 'false cn = an &lt; b 'error End Sub </code></pre> <p>In Case-1 above the string <code>b</code> and <code>c</code> are converted to double and then compared to the value of <code>an</code> and results in proper boolean values as a result, however in Case-2 the program fails to convert the variable <code>b</code> to a double value and throws an error <code>Run Time Error - 13, Type Mismatch</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload