Home > Software engineering >  Either BOF or EOF is True, or the current record from the then does. The question for help
Either BOF or EOF is True, or the current record from the then does. The question for help

Time:09-22

Code is as follows, the data could have been run, after replace the BOF and EOF error, when debugging to Movefirst has a problem,
 Sub DInput () 
Dim I As an Integer, j As Integer

ReDim ObsDP (1 To the Nsc, 1 To TS), ObsDQ (1) To TS, ObsDE (1) To TS 'To a traffic station, an evaporation station as an example

With Rd
. Open the "select * from [ObsDailyP -" + CStr (StationName) + "] where (dt) between "& amp; LongST & amp; "And" & amp; LongET & amp; "Order by asc [dt]," ConnectSys, adOpenStatic, adLockReadOnly
Prompt error. MoveFirst 'here
If the RecordCount & lt;> TS Then
MsgBox "the rainfall data is missing, please check!"
. Close
The Exit Sub
End the If
I=1
Do
For j=1 To the Nsc
If IsNull (Rd (SName (j))) Then
ObsDP (j, I)=0
The Else
ObsDP (j, I)=Rd (SName (j))
End the If
Next j
. MoveNext
I=I + 1
Loop Until the EOF
. Close

MaxOQ=# - 9999
SumOQ=0
. Open the "select * from [ObsDailyQ -" + CStr (StationName) + "] where (dt) between "& amp; LongST & amp; "And" & amp; LongET & amp; "Order by asc [dt]," ConnectSys, adOpenStatic, adLockReadOnly
. MoveFirst
If the RecordCount & lt;> TS Then
MsgBox "traffic data is missing, please check!"
. Close
The Exit Sub
End the If
I=1
Do
If IsNull (Rd) (1) Then
ObsDQ (I)=0
The Else
ObsDQ (I)=Rd (1)
End the If
If ObsDQ (I) & gt; MaxOQ Then
MaxOQ=ObsDQ (I)
ObsI=I
End the If
SumOQ=SumOQ + ObsDQ (I)
. MoveNext
I=I + 1
Loop Until the EOF
. Close

. Open the "select * from [ObsDailyE -" + CStr (StationName) + "] where (Dt) between "& amp; LongST & amp; "And" & amp; LongET & amp; "Order by asc [dt]," ConnectSys, adOpenStatic, adLockReadOnly
. MoveFirst
If the RecordCount & lt;> TS Then
MsgBox "the evaporation data is missing, please check!"
. Close
The Exit Sub
End the If
I=1
Do
If IsNull (Rd) (1) Then
ObsDE (I)=0
The Else
ObsDE (I)=Rd (1)
End the If
. MoveNext
I=I + 1
Loop Until the EOF
. Close

End With

ReDim AvgP (1) To TS
For I=1 To TS
AvgP (I)=0
For j=1 To the Nsc
AvgP (I)=AvgP (I) + ObsDP (j, I) * F (j) 'average daily rainfall
Next j
Next I

End Sub

Sub SaveDResults (ByVal NEi As Integer)
Dim I As an Integer, j As an Integer, NC As Single
Dim AvgOQ As Single, ObsRD As Single, SimRD As Single
Dim ErQ As Single, ErR As Single

AvgOQ=SumOQ/TS
ObsRD=0
SimRD=0
SumLOSQ=0
SumLOQ=0
For I=1 To TS
ObsRD=ObsRD + (ObsDQ (I) - AvgOQ) ^ 2
SimRD=SimRD + (DQResult (I) - ObsDQ (I)) ^ 2
If ObsDQ (I)=0 Or DQResult (I)=0 Then
SumLOSQ=SumLOSQ
The Else
SumLOSQ=SumLOSQ + Abs (Log (ObsDQ (I)/DQResult (I)))
End the If
If ObsDQ (I)=0 Then
SumLOQ=SumLOQ
The Else
SumLOQ=SumLOQ + Abs (Log (ObsDQ (I)))
End the If
Next I
NC=1 - SimRD/ObsRD
NC=Format (NC, "# 0.000")
ErQ=(MaxSQ - MaxOQ)/MaxOQ * 100
ErR=(SumSQ - SumOQ)/SumOQ * 100
ErQ=Format (ErQ, "# 0.00")
# ErR=Format (ErR, "0.00")

If OptiPara=True Then
If FOption=True Or SOption=True Or TOption=True Then
Simfr (NEi)=Abs ((SumSQ - SumOQ)/SumOQ) + Abs (1 - NC)
The Else
Fsample (NEi, simd)=Abs ((SumSQ - SumOQ)/SumOQ) + Abs (1 - NC)
End the If
If FrOption=True Then
Rd., Open the "select * from [SimDCResults -" + CStr (StationName) + "] ", ConnectSys, adOpenDynamic adLockOptimistic,
Rd. AddNew
Rd (" random operation code ")=simsjs
Rd (" session ")=NEi
Rd (" start time ")=FSTime (NEi)
Rd (" runoff depth error (%) ")=ErR
Rd (" flood peak error (%) ")=ErQ
Rd (" poor peak current (time))=SimI - ObsI
Rd (" certainty factor ")=NC
Rd. Update
Rd. Close
End the If
The Else
If FiOption=True Then

ConnectSys. Execute "delete * from [SimDState -" + CStr (StationName) + "] where (Dt) between "& amp; LongST & amp; "And" & amp; LongET & amp; "
"ConnectSys. Execute "delete * from [SimDResults -" + CStr (StationName) + "] where [time] between # "& amp; Format (FSTime (NEi), "YYYY - MM - DD) & amp; "# and #" & amp; Format (FETime (NEi), "YYYY - MM - DD) & amp; "#", "

With Rd
. Open the "select * from [SimDState -" + CStr (StationName) + "] ", ConnectSys, adOpenDynamic adLockOptimistic,
For I=1 To TS
FSTime0=DateAdd (" d ", 1, FSTime0)
LongST0=DatePart (yyyy, FSTime0) * 10000 + DatePart (" m ", FSTime0) * 100 + DatePart (" d ", FSTime0)
For j=1 To the Nsc
The AddNew
Rd (" Dt ")=LongST0
Rd (" Sub ")=j
Rd (" W ")=WW (j, I)
Rd (" Wu ")=WWu (j, I)
Rd (" Wl ")=WWl (j, I)
Rd (" S ")=SS (j, I)
Rd (" Fr ")=FFr (j, I)
. The Update
Next j
Next I
. Close

. Open the "select * from [SimDResults -" + CStr (StationName) + "] ", ConnectSys, adOpenDynamic adLockOptimistic,
For I=1 To TS
FSTime0=DateAdd (" d ", I - 1, FSTime (NEi))
The AddNew
Rd (" session ")=NEi
Rd (" time ")=FSTime0
Rd (" calculation flow ")=DQResult (I)
Rd (" the measured flow ")=ObsDQ (I)
Rd (" average rainfall ")=AvgP (I)
. The Update
Next I
. Close
End With
The Else
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related