Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP how can i load a date from a sequential file

Status
Not open for further replies.

DGEN

Programmer
Oct 29, 2004
17
GB
I have been trying to get a program that i have been working on to load a date but everytime i do this i keep getting an OVERFLOW message.

i have tried numerous things but it does not seem to work is there anybody who can help me with this problem if you could i would be very greatful.
 
i have tried numerous things but it does not seem to work
Well, can you please post what you tried and the expected result ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Could you give the details of the file and the code that you have attempted?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Hi this is the code that i have wrote if somebody can shed some light as to what the problem is i would be most greatful

'------------------------------------------
Private Sub Form_Load()

CurSysDate = Format(dd - mmmm - yy)
CurSysDate = Date
' Read the sequential file
Dim intCtr As Integer ' Loop counter
Dim intVal As Integer ' Read value
Dim intMsg As Integer ' MsgBox()
Dim Vehnum As Integer
'FreeFile
Open "C:\Documents and Settings\Barclay Classics\My Documents\Projects\Vb projects\Vehicle Reminders\CRsys.amt" For Input As #1

For intCtr = 1 To 1
Input #1, intVal
' Display the results in the Immediate window
intMsg = MsgBox("Retrieved a " & intVal & " from Print.txt")
Next intCtr

Close #1

Open "C:\Documents and Settings\Barclay Classics\My Documents\Projects\Vb projects\Vehicle Reminders\Vehicle Database\database.cdb" For Input As #1

For intCtr = 1 To intVal
Input #1, filesave(intCtr)
' Display the results in the Immediate window
intMsg = MsgBox("Retrieved a " & filesave(intCtr) & " from Print.txt")
Next intCtr

Close #1
For Vehnum = 1 To 1
FileOpen = filesave(Vehnum)
Open "C:\Documents and Settings\Barclay Classics\My Documents\Projects\Vb projects\Vehicle Reminders\Vehicles in Active reminder list\" & FileOpen & ".CSD" For Input As #1
'datal = Format(MOT_DDate(Vehnum), "ddmmyy")
'------- Below is the problem area ---------
For loader = 1 To 9

If loader = 1 Then Input #1, VehicleType(Vehnum) 'fine
If loader = 2 Then Input #1, Registration(Vehnum) 'fine
If loader = 3 Then Input #1, Yearstring(Vehnum) 'fine
If loader = 4 Then Input #1, Descriptive(Vehnum) 'fine

'from here onwards the error appears
If loader = 5 Then Input #1, datal '<--- Overflow
If loader = 5 Then MOT_DDate(Vehnum) = datal
If loader = 6 Then Input #1, datal
If loader = 6 Then MOT_SDate(Vehnum) = datal
If loader = 7 Then Input #1, retrieved
If loader = 7 Then TAX_DDate(Vehnum) = datal
If loader = 8 Then Input #1, datal
If loader = 8 Then TAX_SDate(Vehnum) = datal
If loader = 9 Then Input #1, datal
If loader = 9 Then SORN_SDate(Vehnum) = datal
' Display the results in the Immediate window
intMsg = MsgBox("Retrieved " & retrieved & " information successfully")
Next loader
Close #1
Next Vehnum
End Sub
'--------------------------------------------------------

I have Defined Datal as a date in a global.bas

below is the Global.bas source code as in the top i will highlight the various areas

'--------------- Code starts below ---------------------
Global MotDueDate As Date
Global MotDate As Date
Global MotExpired As Boolean
Global TaxDueDate As Date
Global TaxDate As Date
Global TaxExpired As Boolean
Global SafeTCode As Long
Global VeEs As Boolean
Global Earlywarning As Boolean
Global EwEs As Boolean
Global DnES As Boolean
Global DCheck As Boolean
Global CurSysDate As Date
Global activatedte As Date
Global SornDate As Date
Global messages
Public DBase
' All of the below code defines arrays to have a databse
' style interface
Public VehicleDetails(9999)
Public VehicleType(9999) As String
Public make(9999)
Public Registration(9999) As String
Public Descriptive(9999) As String
Public Yearstring(9999)
Global retrieved


Public MOT_DDate(9999) As Date '<- define a database array
Public MOT_SDate(9999) As Date '<- Database like array
Public TAX_DDate(9999) As Date '<-Database array
Public TAX_SDate(9999) As Date '<- Database like array
Public SORN_SDate(9999) As Date '<- Database like array

Public filesave(9999) As String '<----- the save file Array
Global FileOpen '<-------- the file open variable
Global datal As Date '<-------- defined this as a date
Public OnlyOneClick As Boolean
'----------------------------------------------------------
 
Oh and below is what the file(s) im loading contains

Austin 1100 (Cream) - GBX 868E.CSD

start of file
-----------------------
Austin 1100 (Cream)
GBX 868E
1967
Very Good interior
01:01:83
01:01:83
01:01:83
01:01:83
01:01:83
--------------------------
and the database file contains the below

database.CDB

start of file
---------------------------
"Austin 1100 (Cream) - GBX 868E"
---------------------------
 
You're in VBScript forum and your code is not VBS.
Anyway what is the real value of 5th record in the file ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Anything after 5 is a date

this code was written in VB6 what did you mean by saying that it is a vb script forum [neutral]

i am new here see

well anyways do you know what the problem is
 
The title of this forum is 'VBScript Forum'

The forum that would provide you with the best answer is 'Visual Basic(Microsoft): Version 5 & 6'

It is here:
forum222

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
1) There is a VB forum in this site
2) Not answering the question (what is the real value of 5th record) will not help someone to help you.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Oops, I didn't realize you already posted the file content.
01:01:83
The above string when converted to a date will be evaluated as time (due the colon) and so raise the overflow error because 83 seconds is illegal.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top