title: ASP Classic - Type mismatch: 'CInt' - Easy question
body: <p>Having an issue with type conversion in ASP classic.</p>
  
  <p>heres my code:</p>
  
  <pre><code>        Set trainingCost = Server.CreateObject("ADODB.Recordset")
      strSQL3 = "SELECT cost1 FROM tblMain WHERE (Booked = 'Booked') AND (Paid IS NULL) AND (PaidDate BETWEEN '01/04/" &amp; startyear &amp; "' AND '31/03/" &amp; endyear &amp; "')"
      trainingCost.Open strSQL3, Connection
      trainingCost.movefirst
      totalTrainCost = 0
      do while not trainingCost.eof
          trainCost = trainingCost("cost1")
          If NOT isNull(trainCost) then
              trainCostStr = CStr(trainCost)
              trainCostStr = Replace(trainCostStr, "£", "")
              trainCostStr = Replace(trainCostStr, ",", "")
              totalTrainCost = totalTrainCost + CInt(trainCostStr)
          end if
          trainingCost.movenext
      loop 
  
      trainingCost.close
  </code></pre>
  
  <p>when I run this I get the following error:</p>
  
  <p>Microsoft VBScript runtime (0x800A000D)
  Type mismatch: 'CInt' 
  /systems/RFT/v1.2/Extract.asp, line 43</p>
  
  <p>which is "totalTrainCost = totalTrainCost + CInt(trainCostStr)"</p>
  
  <p>Im guessing that the problem is to do with the String value being uncastable to Int in which case is there any way to catch this error? I havent worked with asp classic much so any help would be usefull</p>
  
  <p>cheers</p>
  
  <p>-EDIT-</p>
  
  <p>the type of column cost1 is String as it may contain a number or a sequence of chars eg £10.00 or TBC</p>