Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4617660
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:09:21+00:00 2026-05-22T02:09:21+00:00

I have a function that reads a text file containing two lines, it reads

  • 0

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:

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)'<--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

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 valInt = CLng("18") it works fine. I’m not sure what I’m missing, any help is appreciated.

UPDATE

Ok so I tried running the script again, this time replacing the value in the text file, which was 20110511123500 to something shorter 2011 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.

UPDATE 2

Using double did the trick, thanks G Mastros.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:09:22+00:00Added an answer on May 22, 2026 at 2:09 am

    Maximum Numeric Value Sizes Listed Below:

    Int16: -32768 to 32767

    Int32: -2147483648 to 2147483647

    Int64: -9223372036854775808 to 9223372036854775807

    Double: -1.79769313486232E+308 to 1.79769313486232E+308

    Long: -9223372036854775808 to 9223372036854775807

    Short: -32768 to 32767

    There is also in the System.Numerics namespace a new datatype introduced in .NET 4.0 called the BigInteger (System.Numerics.BigInteger) which can store incredibly large numbers.

    More info can be found here

    CDbl did the trick because the conversion required the right data type based on the numbers total size.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that automatically exports a table into a CSV file, then
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035
I have a function that gets x(a value) and xs(a list) and removes all
I have a function that takes, amongst others, a parameter declared as int privateCount
I have a function that looks like this class NSNode { function insertAfter(NSNode $node)
I have a function that I use called sqlf(), it emulates prepared statements. For
I have a function that is effectively a replacement for print, and I want
I have a function that takes a struct, and I'm trying to store its
I have a function that checks if a cookie (by name) exists or not:
I have a function that resembles the one below. I'm not sure how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.