title: VBScript - "Type Mismatch" Error with InStr Function
body: <p>I have a String like this:</p>
  
  <pre><code>"5/1/2017 7:11:15 PM | String is very long - part 1 - part 999 - 2017-04-28.dots, Replace Existing"
  </code></pre>
  
  <p>This is the sub string I want to find the position in main string:</p>
  
  <pre><code>"String is very long - part 1 - part 999 - 2017-04-28.dots"
  </code></pre>
  
  <p>I tried to find it using <code>InStr</code> Function like this:</p>
  
  <pre><code>MsgBox CStr(InStr("5/1/2017 7:11:15 PM | String is very long - part 1 - part 999 - 2017-04-28.dots, Replace Existing", "String is very long - part 1 - part 999 - 2017-04-28.dots", 1, 1))
  </code></pre>
  
  <p>The result I expected is <code>23</code>.</p>
  
  <p>Instead of the result, it throws the following Error:</p>
  
  <blockquote>
    <p>Type mismatch: '[string: "5/1/2017 7:11:15 PM"]' (Code: 800A000D)</p>
  </blockquote>
  
  <p>As this error depicts, can't I use <code>InStr</code> Function to deal with Strings those have spaces?</p>
  
  <p>Thanks in Advance.</p>