end of file error

Hi there guys, i am having an end of file error when reading from a text-file opened in input mode, but sometimes my code works so i dont understand what goins on here is my code maybe someone may see something i cant see...Sure:

Please note that this is only a fragment of the code!

If Dir(FileName) <> "" Then
Open FileName For Input As #1
Do Until EOF(1)
Input #1, Temp_Humid, Hours, Minutes, Seconds, Days, Months, Years, Physical
Decimal_Temp_Humid = Asc(Temp_Humid) 'Convert ASCII value to decimal from now on
Decimal_Hours = Asc(Hours)
Decimal_Minutes = Asc(Minutes)
Decimal_Seconds = Asc(Seconds)
Decimal_Days = Asc(Days)
Decimal_Months = Asc(Months)
Decimal_Years = Asc(Years)
Decimal_Physical = Asc(Physical)
'Decimal_Temp_Humid = 144
Decimal_Physical = 1
'do software correction here
If Decimal_Physical = 1 Then
' measured humidity and correct with the appropriate algorithm
'perform preparation step 1
Msg = "Relative Humidity Reading(s) (%)"
x_middle = (CLng(Calibration_Values(9)) * 256 + Calibration_Values(10))
Hr1 = (x_middle * 5.02 / 65536 - 0.958) / 0.0307
x_middle = (CLng(Calibration_Values(11)) * 256 + Calibration_Values(12))
Hr2 = (x_middle * 5.02 / 65536 - 0.958) / 0.0307
x_middle = (CLng(Calibration_Values(13)) * 256 + Calibration_Values(14))
Hr3 = (x_middle * 5.02 / 65536 - 0.958) / 0.0307
x_middle = (CLng(Calibration_Values(15)) * 256 + Calibration_Values(16))
Hc1 = (x_middle * 5.02 / 65536 - 0.958) / 0.0307
x_middle = (CLng(Calibration_Values(17)) * 256 + Calibration_Values(18))
Hc2 = (x_middle * 5.02 / 65536 - 0.958) / 0.0307
x_middle = (CLng(Calibration_Values(19)) * 256 + Calibration_Values(20))
Hc3 = (x_middle * 5.02 / 65536 - 0.958) / 0.0307
Err1 = Hc1 - Hr1
Err2 = Hc2 - Hr2
Err3 = Hc3 - Hr3
B = ((Hr2 ^ 2 - Hr1 ^ 2) * (Err3 - Err1) + (Hr3 ^ 2) * (Err1 - Err2) + (Hr1 ^ 2) * (Err2 - Err1)) / ((Hr2 ^ 2 - Hr1 ^ 2) * (Hr3 - Hr1) + (Hr3 ^ 2 - Hr1 ^ 2) * (Hr1 - Hr2))
A = (Err2 - Err1 + B * (Hr1 - Hr2)) / (Hr2 ^ 2 - Hr1 ^ 2)
C = Err1 - A * Hr1 ^ 2 - B * Hr1
'perform step 2 execution
Hc = ((Decimal_Temp_Humid * 256) * 5.02 / 65536 - 0.958) / 0.0307
Hcorr = Hc - (A * Hc ^ 2 + B * Hc + C)
Decimal_Temp_Humid = Left(Hcorr, 5) 'corrected humidity reading
Else
'measured temperature and correct appropriately
'perform Step 1 which is preparation
Msg = "Temperature Reading(s)(

Comments

  • : Hi there guys, i am having an end of file error when reading from a
    : text-file opened in input mode, but sometimes my code works so i
    : dont understand what goins on here is my code maybe someone may see
    : something i cant see...Sure:
    :
    : Please note that this is only a fragment of the code!
    :
    : If Dir(FileName) <> "" Then
    : Open FileName For Input As #1
    : Do Until EOF(1)
    : Input #1, Temp_Humid, Hours, Minutes, Seconds,
    : Days, Months, Years, Physical
    : Decimal_Temp_Humid = Asc(Temp_Humid) 'Convert
    : ASCII value to decimal from now on
    : Decimal_Hours = Asc(Hours)
    : Decimal_Minutes = Asc(Minutes)
    : Decimal_Seconds = Asc(Seconds)
    : Decimal_Days = Asc(Days)
    : Decimal_Months = Asc(Months)
    : Decimal_Years = Asc(Years)
    : Decimal_Physical = Asc(Physical)
    : 'Decimal_Temp_Humid = 144
    : Decimal_Physical = 1
    : 'do software correction here
    : If Decimal_Physical = 1 Then
    : ' measured humidity and correct with the
    : appropriate algorithm
    : 'perform preparation step 1
    : Msg = "Relative Humidity Reading(s) (%)"
    : x_middle = (CLng(Calibration_Values(9)) *
    : 256 + Calibration_Values(10))
    : Hr1 = (x_middle * 5.02 / 65536 - 0.958) /
    : 0.0307
    : x_middle = (CLng(Calibration_Values(11)) *
    : 256 + Calibration_Values(12))
    : Hr2 = (x_middle * 5.02 / 65536 - 0.958) /
    : 0.0307
    : x_middle = (CLng(Calibration_Values(13)) *
    : 256 + Calibration_Values(14))
    : Hr3 = (x_middle * 5.02 / 65536 - 0.958) /
    : 0.0307
    : x_middle = (CLng(Calibration_Values(15)) *
    : 256 + Calibration_Values(16))
    : Hc1 = (x_middle * 5.02 / 65536 - 0.958) /
    : 0.0307
    : x_middle = (CLng(Calibration_Values(17)) *
    : 256 + Calibration_Values(18))
    : Hc2 = (x_middle * 5.02 / 65536 - 0.958) /
    : 0.0307
    : x_middle = (CLng(Calibration_Values(19)) *
    : 256 + Calibration_Values(20))
    : Hc3 = (x_middle * 5.02 / 65536 - 0.958) /
    : 0.0307
    : Err1 = Hc1 - Hr1
    : Err2 = Hc2 - Hr2
    : Err3 = Hc3 - Hr3
    : B = ((Hr2 ^ 2 - Hr1 ^ 2) * (Err3 - Err1) +
    : (Hr3 ^ 2) * (Err1 - Err2) + (Hr1 ^ 2) * (Err2 - Err1)) / ((Hr2 ^ 2 -
    : Hr1 ^ 2) * (Hr3 - Hr1) + (Hr3 ^ 2 - Hr1 ^ 2) * (Hr1 - Hr2))
    : A = (Err2 - Err1 + B * (Hr1 - Hr2)) / (Hr2 ^
    : 2 - Hr1 ^ 2)
    : C = Err1 - A * Hr1 ^ 2 - B * Hr1
    : 'perform step 2 execution
    : Hc = ((Decimal_Temp_Humid * 256) * 5.02 /
    : 65536 - 0.958) / 0.0307
    : Hcorr = Hc - (A * Hc ^ 2 + B * Hc + C)
    : Decimal_Temp_Humid = Left(Hcorr, 5)
    : 'corrected humidity reading
    : Else
    : 'measured temperature and correct
    : appropriately
    : 'perform Step 1 which is preparation
    : Msg = "Temperature Reading(s)(
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion