title: VBScript convert string to integer
body: <p>I have a function that reads a text file containing two lines, it reads the second line and tries to convert the string to a Long integer.  My problem is that it's not converting the string, the code for the function is as follows:</p>
  
  <pre><code>Function getLastUsed (txtFilePath)
      'Read timestamp created by full backup script
      Const ForReading = 1
      'Error Handling
      On Error Resume Next
      Err.Clear
      Set objFile = Fso.OpenTextFile(txtFilePath, ForReading)
      'Read if file was successfully opened, else return 0
      If Err.Number = 0 Then
          'Value will be on the second line, so readLine twice
          Dim valString
          valString = objFile.Readline
          valString = objFile.Readline
          objFile.Close
          'If not empty continue, else return 0
          If Not IsEmpty(valString) Then
              'Return value is IsNumeric, else return 0
              If IsNumeric(valString) Then
                  Dim valInt
                  valInt = CLng(valString)'&lt;--Won't convert, variable valInt is empty after this line
                  getLastUsed = valInt
              Else
                  getLastUsed = 0
              End If
          Else
              getLastUsed = 0
          End If
      Else
          getLastUsed = 0
      End If
  End Function
  </code></pre>
  
  <p>I'm using Visual Studio to step through and debug, looking at the 'valInt' variable, it is empty after I call CLng or CInt.  However, if I hardcode a value, like <code>valInt = CLng("18")</code> it works fine.  I'm not sure what I'm missing, any help is appreciated.</p>
  
  <p>UPDATE</p>
  
  <p>Ok so I tried running the script again, this time replacing the value in the text file, which was <code>20110511123500</code> to something shorter <code>2011</code> and it worked.  So it seems like it was a precision issue.  That leads to a second question, what's the largest number VBScript can handle as far as conversion is concerned?  The numeric value indicated is the amount of disk space on a hard drive, so I need to be able to read large numbers.  Thanks for the hint Pepto.</p>
  
  <p>UPDATE 2</p>
  
  <p>Using double did the trick, thanks <strong>G Mastros</strong>. </p>