title: If statement check for a string start with a specific number
body: <p>I wanted to check if the data begins with <code>&quot;01&quot;</code> (meaning it's a phone number) and I wanted to add <code>&quot;60&quot;</code> in front of the phone number and replace the dash inside the string to nothing.</p>
  <p>I get this error in this line <code>if Field Like &quot;01*&quot; Then</code></p>
  <blockquote>
  <p>Microsoft VBScript runtime error '800a0023'</p>
  <p>Sub or Function not defined</p>
  </blockquote>
  <p>Hope someone may be able to tell me what's wrong.</p>
  <pre><code>&lt;%Option Explicit%&gt;
  &lt;%
  Dim strConn, strScriptName,strSQL
  
  strConn = Application(&quot;eDSNSMS&quot;)
  
  strSQL = Request.querystring(&quot;SQL&quot;)
  
  sub Write_CSV_From_Recordset(RS)
    if RS.EOF then
          exit sub
      end if
  
      dim RX
      set RX = new RegExp
          RX.Pattern = &quot;\r|\n|,|&quot;&quot;&quot;
  
      dim i
      dim Field
      dim Separator
  
      do until RS.EOF
          Separator = &quot;&quot;
          for i = 0 to RS.Fields.Count - 1
              Field = RS.Fields(i).Value &amp; &quot;&quot;
              if RX.Test(Field) then
                  Field = &quot;&quot;&quot;&quot; &amp; Replace(Field, &quot;&quot;&quot;&quot;, &quot;&quot;&quot;&quot;&quot;&quot;) &amp; &quot;&quot;&quot;&quot;
              end if
              if Field Like &quot;01*&quot; Then
                  Field = &quot;60&quot; + Field
                  Field = &quot;&quot;&quot;&quot; &amp; Replace(Field, &quot;-&quot;, &quot;&quot;) &amp; &quot;&quot;&quot;&quot;
              end if
              Response.Write Separator &amp; Field
              Separator = &quot;,&quot;
          next
          Response.Write vbNewLine
          RS.MoveNext
      loop
  end sub
      
  Dim objRS, objConn
  
  set objConn = server.CreateObject(&quot;ADODB.Connection&quot;)
  objConn.ConnectionString = strConn
  objConn.Open
  set objRS = server.CreateObject(&quot;ADODB.RecordSet&quot;)
  objRS.Open strSQL, strConn, 0, 1
  
  Write_CSV_From_Recordset objRS
  Response.ContentType = &quot;text/csv&quot;
  Response.AddHeader &quot;Content-Disposition&quot;, &quot;attachment;filename=export.csv&quot;
  %&gt;
  </code></pre>