I tried to put an "on error" statement in a routine and got the message
that I cannot user "on error" and a lamda or query expression in the
same routine.
Help does not list anything useful for explaining a "lamda" expression
and so I don't know what one is and I am not doing any database stuff in
the entire program.
So what does this error message really mean and what can I do to get an
On Error into the routine?
NO, DON'T tell me to use Try/Catch because it is an incomplete
implementation that does not allow control to get back to the failing
line of code after attempting a fixup of the problem.
Mike
Here is the rather long routine that gets the error, just in case
someone wants to look at it. It was written when I was just learning
VB9 and is certainly set up from the perspective of a long-time VB6
coder. There are fixups to be made, for sure to modernize it. Just
have not had the time to implement them as of yet. Mostly, I want to
get rid of the old WinSock ActiveX control for UDP data retrieval but
have not figured out how as of yet. Possibly an answer is already
present in another thread.
--------------------------------------------------------------------
Private Sub wsInverter_DataArrival(ByVal eventSender As System.Object,
ByVal eventArgs As
AxMSWinsockLib.DMSWinsockControlEvents_DataArrival Event) Handles
wsInverter.DataArrival
Dim iNewFace As Short
Dim sLittleEndian As String
Dim sBigEndian As String
Dim i As Integer
Dim iState As Integer
Dim iFault2 As Integer
Dim fCTemp As Decimal
Dim fFTemp As Decimal
Dim s As String
'Dim sFixed As String
Dim lUniqueReturn As Integer
Dim cDCVolts As Decimal
Dim cACAmps As Decimal
Dim cACPower As Decimal
Static lPrevAmbient As Integer = -300
Dim Bytes() As Byte
'objData = Nothing ' This line is just to make the error lister
happy. It can be removed but a warning will appear.
Bytes = Nothing
wsInverter.GetData(Bytes)
lblPktStatus.Text = "OK (RTT: " & Format(GetTickCount - glRTT,
"###,##0") & " ms.)"
'Move the next sample to the 30 second mark to get 1 response per
each unique minute all day (most probably)
Select Case Second(Now)
Case 0 To 28
Timer1.Interval = 60000 + (30 - Second(Now)) * 1000
Case 29
Timer1.Interval = 60300
Case 30
Timer1.Interval = 60000
Case 31
Timer1.Interval = 59600
Case 32 To 59
Timer1.Interval = 60000 + (30 - Second(Now)) * 1000
End Select
Timer1.Enabled = False
Timer1.Enabled = True
lblPktRecvTime.Text = CStr(TimeOfDay)
sLittleEndian = MakeString(Bytes)
'Debug.Print(Asc(objData.ToString(1)))
sBigEndian = ""
'sFixed = "Big Endian : "
'The only difference between sFixed and sBigEndian is that sFixed
has a space every word (4 hex digits) for human visual consumption.
For i = 1 To eventArgs.bytesTotal Step 2
'sFixed = sFixed & Strings.Mid(sLittleEndian, i * 2 + 1, 2) &
Strings.Mid(sLittleEndian, i * 2 - 1, 2)
sBigEndian = sBigEndian & Strings.Mid(sLittleEndian, i * 2 + 1, 2)
& Strings.Mid(sLittleEndian, i * 2 - 1, 2)
'sFixed = sFixed & " "
Next
'**Debug.Print("Little Endian (Orig): " & sLittleEndian)
'Debug.Print("Big Endian (Fixed): " & sBigEndian)
'**Debug.Print("---------------------")
lUniqueReturn = CInt("&H" & Strings.Mid(sBigEndian, PKT_UniqueNo,
4))
'**Debug.Print(Now() & " Data for Inverter with Internal ID " &
lUniqueReturn)
'**Debug.Print(" 1 2 3 4 5 6 7 8 910 1112 1314
1516 1718 1920 2122 2324 2526 2728 2930 3132 3334 3536")
'**Debug.Print(sFixed)
'Print #gDebugFile, Now() & " 1 2 3 4 5 6 7 8 910
1112 1314 1516 1718 1920 2122 2324 2526 2728 2930 3132 3334 3536"
'Print #gDebugFile, Now() & " " & sFixed
If eventArgs.bytesTotal < 36 Then
StatusAdd("Wrong number of bytes received (should have been 36): "
& eventArgs.bytesTotal)
Exit Sub
End If
'Identification info
gsModel_No = CStr(CInt("&H" & Strings.Mid(sBigEndian, PKT_Model,
4)))
gsFamily_Name = gsFamily(CInt(gsModel_No))
gsModel_Name = gsModel(CInt(gsModel_No))
giSerial_Number = CInt("&H" & Strings.Mid(sBigEndian,
PKT_SerialHigh, 4) & Strings.Mid(sBigEndian, PKT_SerialLow, 4))
gsFirmware_Version = CInt("&H" & Strings.Mid(sBigEndian,
PKT_FirmwareHigh, 2)) & "." & CInt("&H" & Strings.Mid(sBigEndian,
PKT_FirmwareLow, 2))
gsBoard_Type = CStr(CInt("&H" & Strings.Mid(sBigEndian,
PKT_BoardType, 4)))
gsBoard_Serial = CStr(CInt("&H" & Strings.Mid(sBigEndian,
PKT_BoardSerial, 4)))
'DC Voltage -- needed in the fault determination code, below
cDCVolts = CDec("&H" & Strings.Mid(sBigEndian, PKT_DCVoltage, 4)) *
gdDC_Voltage(CInt(gsModel_No))
lblDCVolts.Text = Format(cDCVolts, "###0.0") & " VDC"
'Status
iState = CInt("&H" & Strings.Mid(sBigEndian, PKT_State1, 4))
iFault2 = CInt("&H" & Strings.Mid(sBigEndian, PKT_State2, 4))
lblStatus1.ForeColor = System.Drawing.Color.Red
Select Case iState
Case &H15
lblStatus1.Text = "Online"
lblStatus1.ForeColor = System.Drawing.Color.Blue
lblStatus2.Text = ""
iNewFace = Faces.HAPPY_FACE
Case &H80
iNewFace = Faces.RED_FACE
lblStatus1.Text = "Error -- Fault code " & iFault2 ' In case
nothing hits, below, something to see.
If iFault2 = &H1000 Then
lblStatus1.Text = "Deep Sleeping"
lblStatus2.Text = "General Voltage Fault"
iNewFace = Faces.SLEEPY_FACE
End If
If iFault2 = &H200 OrElse iFault2 = &H1200 Then lblStatus1.Text
= "Low Voltage Fault"
If CBool(iFault2 And &H8000) Then lblStatus1.Text = "PDPA Fault"
: Beep()
If CBool(iFault2 And &H400) Then lblStatus1.Text = "Ground
Fault" : Beep()
If CBool(iFault2 And &H200) Then lblStatus1.Text = "Low Power
Fault"
If CBool(iFault2 And &H100) Then lblStatus1.Text = "CPU Load
Fault" : Beep()
If CBool(iFault2 And &H40) Then lblStatus1.Text = "Overcurrent
Fault" : Beep()
If CBool(iFault2 And &H20) Then lblStatus1.Text = "Precharge
Fault" : Beep()
If CBool(iFault2 And &H4) Then lblStatus1.Text = "Heatsync Over
Temperature Fault" : Beep()
If CBool(iFault2 And &H1) Then lblStatus1.Text = "Ambient
Temperature Fault" : Beep()
Case Else
lblStatus1.Text = "Light Sleeping"
iNewFace = Faces.SLEEPY_FACE
lblStatus1.ForeColor = System.Drawing.Color.Black
End Select
'Temperature
fCTemp = CDec(CDec("&H" & Strings.Mid(sBigEndian, PKT_Temperature,
4)) * 0.01)
fFTemp = CDec(fCTemp * 1.8 + 32)
lblFinTemp.Text = Format(fCTemp, "##0.0") & "° C / " &
Format(fFTemp, "#0.0") & "° F"
'AC Voltage
lblACVolts.Text = Format(CDec("&H" & Strings.Mid(sBigEndian,
PKT_ACVolts, 4)) * gdAC_Voltage(CInt(gsModel_No)), "###0.0") & " VAC"
If iFault2 <&H1000 Then
'AC Current
cACAmps = CDec("&H" & Strings.Mid(sBigEndian, PKT_ACCurrent, 4)) *
gdAC_Current(CInt(gsModel_No))
lblACCurrent.Text = Format(cACAmps, "#,##0.0") & " Amperes"
'AC Power
cACPower = CDec("&H" & Strings.Mid(sBigEndian, PKT_ACPower, 4)) *
gdAC_Power(CInt(gsModel_No))
If CDbl(cACPower) glPeakWattsThisDay(glHistoricalDateCt) Then
glPeakWattsThisDay(glHistoricalDateCt) = CInt(cACPower)
lblACPower.Text = Format(cACPower, "##,##0") & " Watts/Hours"
Else
lblACCurrent.Text = "" : lblACPower.Text = "" : cACAmps = CDec(0)
: cACPower = CDec(0) ' Clear out references during fault(s) per the
PVM1010 manual.
End If
'Lifetime KWs
glLifetimeKW = CInt("&H" & Strings.Mid(sBigEndian, PKT_LifeKWHigh,
4) & Strings.Mid(sBigEndian, PKT_LifeKWLow, 4))
lblLifeKW.Text = Format(glLifetimeKW, "###,##0") & " KW"
If glMidNightKWs = 0 Then glMidNightKWs = CInt(glLifetimeKW) ' In
case there is no TrendData file.
glKWsThisDay(glHistoricalDateCt) = glLifetimeKW - glMidNightKWs
gsHistoricalDate(glHistoricalDateCt) = Format(Now, "Short Date")
gbQueryStatus = REQ_PACKET ' This one worked. Next time, query
again.
If Minute(Now()) Mod 15 = 0 Then ' glWhichFace = Faces.HAPPY_FACE
AndAlso
Dim newThread As New Thread(AddressOf GetAmbientCondx) ' Do on
thread other than main to avoid lock ups.
newThread.Start()
End If
'Don't fill space with zero power entries (mostly night time) except
make a midnight entry for the next day.
'The following problem seems to have been fixed by other coding and
is left for historical information only:
'Without the midnight entry, the program cannot tell if the last
exit was before or after midnight and could report
'the wrong KWs after restart midnight.
If CDbl(cACPower) 10 OrElse cDCVolts 100 OrElse CBool((iFault2
And &H200)) OrElse (Hour(Now) = 0 And Minute(Now()) = 0) Then
If gbTrendFileOpenStatus = TREND_FILE_CLOSED Then OpenTrendFile()
'giTrendFileNo = FreeFile()
'FileOpen(giTrendFileNo, My.Application.Info.DirectoryPath & "\" &
TrendFileName, OpenMode.Append, OpenAccess.Write)
'gbTrendFileOpenStatus = TREND_FILE_OPEN
'End If
s = Format(Now(), "short date") & "," & Format(Now(), "Hmm") & ","
& _
lUniqueReturn & "," & _
Format(fFTemp, "###0.0") & "," & _
Format(cDCVolts, "###0.0") & "," & _
Format(cACAmps, "###0.0") & "," & _
Format(cACPower, "###0.0") & "," & _
glLifetimeKW
lckCondx.EnterReadLock()
If lPrevAmbient <glAmbientTemp Then
s &= "," & glAmbientTemp
lPrevAmbient = glAmbientTemp
End If
lckCondx.ExitReadLock()
'Debug.Print(s)
'On Error GoTo CannotWrite
PrintLine(giTrendFileNo, s)
'To use Flush here, must convert to StreamWriter
'Using sw As StreamWriter = File.CreateText(FILE_NAME) ' First
time, use File.CreateText then use File.AppendText
' sw.WriteLine("This is my file.")
' sw.WriteLine("I can write ints {0} or floats {1}, and so on.",
1, 4.2)
' sw.Close()
'End Using
gsTrendTimeToday(glTrendCtToday) = Format(Now, "Hmm")
glTrendPowerToday(glTrendCtToday) = CInt(cACPower)
glTrendDCVoltsToday(glTrendCtToday) = CInt(cDCVolts)
glTrendCtToday = glTrendCtToday + 1
DoCorrectGraphOnDataArrival(NOT_YESTERDAY)
End If
If gdtToday <CDate(Format(Now, "M/d/yyyy")) Then
HandleDateChange() ' Do Midnight code now
If glWhichFace <iNewFace Then
Select Case iNewFace
Case Faces.HAPPY_FACE
Me.Icon = My.Resources.Happy_Face
Case Faces.MEDIUM_FACE
Me.Icon = My.Resources.Medium_Face
Case Faces.SAD_FACE
Me.Icon = My.Resources.Sad_Face
Case Faces.RED_FACE
Me.Icon = My.Resources.Red_Face
Case Faces.SLEEPY_FACE
Me.Icon = My.Resources.Sleeping_Face
End Select
NotifyIcon.Icon = Me.Icon
End If
'The Trend file gets reopened for one more write at midnight. Now
close it down, if opened and sleeping.
If iNewFace = Faces.SLEEPY_FACE AndAlso glWhichFace <iNewFace
AndAlso gbTrendFileOpenStatus = TREND_FILE_OPEN Then
FileClose(giTrendFileNo)
gbTrendFileOpenStatus = TREND_FILE_CLOSED
'If we are asleep and the FTP site is defined, it is after noon
and no FTP has been done then FTP the file to the backup site.
If Not gbTrendFile_Daily_FTP_Done AndAlso gsFTPSite <"" AndAlso
Hour(Now) 12 Then DoFTP_TrendFile()
End If
If glWhichFace <iNewFace Then
Dim NewFace As Faces = CType(iNewFace, Faces)
StatusAdd("Changed ICONs to " & NewFace.ToString)
glWhichFace = iNewFace
NewFace = Nothing
End If
'This is a stop gap in case the program was not running at midnight
but was started the next day.
'I guess this obviates the need for the midnight entry but I will
leave it in. I takes so little space and
'it is comfortable there.
If Format(gdtLastTrendDate, "short date") <Format(Now, "short
date") Then
gdtLastTrendDate = Now
glMidNightKWs = glLifetimeKW
End If
'Keep trying to FTP once per hour until it is done properly.
If glWhichFace = Faces.SLEEPY_FACE AndAlso Not
gbTrendFile_Daily_FTP_Done AndAlso Minute(Now) = 0 AndAlso Hour(Now) >
12 Then DoFTP_TrendFile()
lckCondx.EnterReadLock()
If Strings.UCase(gsWX_WindDir) = "CALM" Then
lblWindInfo.Text = gsWX_WindDir & vbCrLf & gsUpdtTime ' ° removed
Else
lblWindInfo.Text = gsWX_WindDir & " " & gsWX_WindSpeed & vbCrLf &
gsUpdtTime ' ° removed
End If
Application.UseWaitCursor = False
lblAmbient.Text = CStr(glAmbientTemp) & "° " & gsTempUnit & " / " &
gsWX_Condx
lckCondx.ExitReadLock()
CannotWrite:
StatusAdd("Cannot write to TrendFile, trying to open again.")
OpenTrendFile()
Resume
End Sub 5 2216
<Ju********@home.netwrote in message
news:nm********************************@4ax.com...
>I tried to put an "on error" statement in a routine and got the message
that I cannot user "on error" and a lamda or query expression in the
same routine.
Help does not list anything useful for explaining a "lamda" expression
and so I don't know what one is and I am not doing any database stuff in
the entire program.
So what does this error message really mean and what can I do to get an
On Error into the routine?
NO, DON'T tell me to use Try/Catch because it is an incomplete
implementation that does not allow control to get back to the failing
line of code after attempting a fixup of the problem.
Mike
Here is the rather long routine that gets the error, just in case
someone wants to look at it. It was written when I was just learning
VB9 and is certainly set up from the perspective of a long-time VB6
coder. There are fixups to be made, for sure to modernize it. Just
have not had the time to implement them as of yet. Mostly, I want to
get rid of the old WinSock ActiveX control for UDP data retrieval but
have not figured out how as of yet. Possibly an answer is already
present in another thread.
--------------------------------------------------------------------
Private Sub wsInverter_DataArrival(ByVal eventSender As System.Object,
ByVal eventArgs As
AxMSWinsockLib.DMSWinsockControlEvents_DataArrival Event) Handles
wsInverter.DataArrival
Dim iNewFace As Short
Dim sLittleEndian As String
Dim sBigEndian As String
Dim i As Integer
Dim iState As Integer
Dim iFault2 As Integer
Dim fCTemp As Decimal
Dim fFTemp As Decimal
Dim s As String
'Dim sFixed As String
Dim lUniqueReturn As Integer
Dim cDCVolts As Decimal
Dim cACAmps As Decimal
Dim cACPower As Decimal
Static lPrevAmbient As Integer = -300
Dim Bytes() As Byte
'objData = Nothing ' This line is just to make the error lister
happy. It can be removed but a warning will appear.
Bytes = Nothing
wsInverter.GetData(Bytes)
lblPktStatus.Text = "OK (RTT: " & Format(GetTickCount - glRTT,
"###,##0") & " ms.)"
'Move the next sample to the 30 second mark to get 1 response per
each unique minute all day (most probably)
Select Case Second(Now)
Case 0 To 28
Timer1.Interval = 60000 + (30 - Second(Now)) * 1000
Case 29
Timer1.Interval = 60300
Case 30
Timer1.Interval = 60000
Case 31
Timer1.Interval = 59600
Case 32 To 59
Timer1.Interval = 60000 + (30 - Second(Now)) * 1000
End Select
Timer1.Enabled = False
Timer1.Enabled = True
lblPktRecvTime.Text = CStr(TimeOfDay)
sLittleEndian = MakeString(Bytes)
'Debug.Print(Asc(objData.ToString(1)))
sBigEndian = ""
'sFixed = "Big Endian : "
'The only difference between sFixed and sBigEndian is that sFixed
has a space every word (4 hex digits) for human visual consumption.
For i = 1 To eventArgs.bytesTotal Step 2
'sFixed = sFixed & Strings.Mid(sLittleEndian, i * 2 + 1, 2) &
Strings.Mid(sLittleEndian, i * 2 - 1, 2)
sBigEndian = sBigEndian & Strings.Mid(sLittleEndian, i * 2 + 1, 2)
& Strings.Mid(sLittleEndian, i * 2 - 1, 2)
'sFixed = sFixed & " "
Next
'**Debug.Print("Little Endian (Orig): " & sLittleEndian)
'Debug.Print("Big Endian (Fixed): " & sBigEndian)
'**Debug.Print("---------------------")
lUniqueReturn = CInt("&H" & Strings.Mid(sBigEndian, PKT_UniqueNo,
4))
'**Debug.Print(Now() & " Data for Inverter with Internal ID " &
lUniqueReturn)
'**Debug.Print(" 1 2 3 4 5 6 7 8 910 1112 1314
1516 1718 1920 2122 2324 2526 2728 2930 3132 3334 3536")
'**Debug.Print(sFixed)
'Print #gDebugFile, Now() & " 1 2 3 4 5 6 7 8 910
1112 1314 1516 1718 1920 2122 2324 2526 2728 2930 3132 3334 3536"
'Print #gDebugFile, Now() & " " & sFixed
If eventArgs.bytesTotal < 36 Then
StatusAdd("Wrong number of bytes received (should have been 36): "
& eventArgs.bytesTotal)
Exit Sub
End If
'Identification info
gsModel_No = CStr(CInt("&H" & Strings.Mid(sBigEndian, PKT_Model,
4)))
gsFamily_Name = gsFamily(CInt(gsModel_No))
gsModel_Name = gsModel(CInt(gsModel_No))
giSerial_Number = CInt("&H" & Strings.Mid(sBigEndian,
PKT_SerialHigh, 4) & Strings.Mid(sBigEndian, PKT_SerialLow, 4))
gsFirmware_Version = CInt("&H" & Strings.Mid(sBigEndian,
PKT_FirmwareHigh, 2)) & "." & CInt("&H" & Strings.Mid(sBigEndian,
PKT_FirmwareLow, 2))
gsBoard_Type = CStr(CInt("&H" & Strings.Mid(sBigEndian,
PKT_BoardType, 4)))
gsBoard_Serial = CStr(CInt("&H" & Strings.Mid(sBigEndian,
PKT_BoardSerial, 4)))
'DC Voltage -- needed in the fault determination code, below
cDCVolts = CDec("&H" & Strings.Mid(sBigEndian, PKT_DCVoltage, 4)) *
gdDC_Voltage(CInt(gsModel_No))
lblDCVolts.Text = Format(cDCVolts, "###0.0") & " VDC"
'Status
iState = CInt("&H" & Strings.Mid(sBigEndian, PKT_State1, 4))
iFault2 = CInt("&H" & Strings.Mid(sBigEndian, PKT_State2, 4))
lblStatus1.ForeColor = System.Drawing.Color.Red
Select Case iState
Case &H15
lblStatus1.Text = "Online"
lblStatus1.ForeColor = System.Drawing.Color.Blue
lblStatus2.Text = ""
iNewFace = Faces.HAPPY_FACE
Case &H80
iNewFace = Faces.RED_FACE
lblStatus1.Text = "Error -- Fault code " & iFault2 ' In case
nothing hits, below, something to see.
If iFault2 = &H1000 Then
lblStatus1.Text = "Deep Sleeping"
lblStatus2.Text = "General Voltage Fault"
iNewFace = Faces.SLEEPY_FACE
End If
If iFault2 = &H200 OrElse iFault2 = &H1200 Then lblStatus1.Text
= "Low Voltage Fault"
If CBool(iFault2 And &H8000) Then lblStatus1.Text = "PDPA Fault"
: Beep()
If CBool(iFault2 And &H400) Then lblStatus1.Text = "Ground
Fault" : Beep()
If CBool(iFault2 And &H200) Then lblStatus1.Text = "Low Power
Fault"
If CBool(iFault2 And &H100) Then lblStatus1.Text = "CPU Load
Fault" : Beep()
If CBool(iFault2 And &H40) Then lblStatus1.Text = "Overcurrent
Fault" : Beep()
If CBool(iFault2 And &H20) Then lblStatus1.Text = "Precharge
Fault" : Beep()
If CBool(iFault2 And &H4) Then lblStatus1.Text = "Heatsync Over
Temperature Fault" : Beep()
If CBool(iFault2 And &H1) Then lblStatus1.Text = "Ambient
Temperature Fault" : Beep()
Case Else
lblStatus1.Text = "Light Sleeping"
iNewFace = Faces.SLEEPY_FACE
lblStatus1.ForeColor = System.Drawing.Color.Black
End Select
'Temperature
fCTemp = CDec(CDec("&H" & Strings.Mid(sBigEndian, PKT_Temperature,
4)) * 0.01)
fFTemp = CDec(fCTemp * 1.8 + 32)
lblFinTemp.Text = Format(fCTemp, "##0.0") & "° C / " &
Format(fFTemp, "#0.0") & "° F"
'AC Voltage
lblACVolts.Text = Format(CDec("&H" & Strings.Mid(sBigEndian,
PKT_ACVolts, 4)) * gdAC_Voltage(CInt(gsModel_No)), "###0.0") & " VAC"
If iFault2 <&H1000 Then
'AC Current
cACAmps = CDec("&H" & Strings.Mid(sBigEndian, PKT_ACCurrent, 4)) *
gdAC_Current(CInt(gsModel_No))
lblACCurrent.Text = Format(cACAmps, "#,##0.0") & " Amperes"
'AC Power
cACPower = CDec("&H" & Strings.Mid(sBigEndian, PKT_ACPower, 4)) *
gdAC_Power(CInt(gsModel_No))
If CDbl(cACPower) glPeakWattsThisDay(glHistoricalDateCt) Then
glPeakWattsThisDay(glHistoricalDateCt) = CInt(cACPower)
lblACPower.Text = Format(cACPower, "##,##0") & " Watts/Hours"
Else
lblACCurrent.Text = "" : lblACPower.Text = "" : cACAmps = CDec(0)
: cACPower = CDec(0) ' Clear out references during fault(s) per the
PVM1010 manual.
End If
'Lifetime KWs
glLifetimeKW = CInt("&H" & Strings.Mid(sBigEndian, PKT_LifeKWHigh,
4) & Strings.Mid(sBigEndian, PKT_LifeKWLow, 4))
lblLifeKW.Text = Format(glLifetimeKW, "###,##0") & " KW"
If glMidNightKWs = 0 Then glMidNightKWs = CInt(glLifetimeKW) ' In
case there is no TrendData file.
glKWsThisDay(glHistoricalDateCt) = glLifetimeKW - glMidNightKWs
gsHistoricalDate(glHistoricalDateCt) = Format(Now, "Short Date")
gbQueryStatus = REQ_PACKET ' This one worked. Next time, query
again.
If Minute(Now()) Mod 15 = 0 Then ' glWhichFace = Faces.HAPPY_FACE
AndAlso
Dim newThread As New Thread(AddressOf GetAmbientCondx) ' Do on
thread other than main to avoid lock ups.
newThread.Start()
End If
'Don't fill space with zero power entries (mostly night time) except
make a midnight entry for the next day.
'The following problem seems to have been fixed by other coding and
is left for historical information only:
'Without the midnight entry, the program cannot tell if the last
exit was before or after midnight and could report
'the wrong KWs after restart midnight.
If CDbl(cACPower) 10 OrElse cDCVolts 100 OrElse CBool((iFault2
And &H200)) OrElse (Hour(Now) = 0 And Minute(Now()) = 0) Then
If gbTrendFileOpenStatus = TREND_FILE_CLOSED Then OpenTrendFile()
'giTrendFileNo = FreeFile()
'FileOpen(giTrendFileNo, My.Application.Info.DirectoryPath & "\" &
TrendFileName, OpenMode.Append, OpenAccess.Write)
'gbTrendFileOpenStatus = TREND_FILE_OPEN
'End If
s = Format(Now(), "short date") & "," & Format(Now(), "Hmm") & ","
& _
lUniqueReturn & "," & _
Format(fFTemp, "###0.0") & "," & _
Format(cDCVolts, "###0.0") & "," & _
Format(cACAmps, "###0.0") & "," & _
Format(cACPower, "###0.0") & "," & _
glLifetimeKW
lckCondx.EnterReadLock()
If lPrevAmbient <glAmbientTemp Then
s &= "," & glAmbientTemp
lPrevAmbient = glAmbientTemp
End If
lckCondx.ExitReadLock()
'Debug.Print(s)
'On Error GoTo CannotWrite
PrintLine(giTrendFileNo, s)
'To use Flush here, must convert to StreamWriter
'Using sw As StreamWriter = File.CreateText(FILE_NAME) ' First
time, use File.CreateText then use File.AppendText
' sw.WriteLine("This is my file.")
' sw.WriteLine("I can write ints {0} or floats {1}, and so on.",
1, 4.2)
' sw.Close()
'End Using
gsTrendTimeToday(glTrendCtToday) = Format(Now, "Hmm")
glTrendPowerToday(glTrendCtToday) = CInt(cACPower)
glTrendDCVoltsToday(glTrendCtToday) = CInt(cDCVolts)
glTrendCtToday = glTrendCtToday + 1
DoCorrectGraphOnDataArrival(NOT_YESTERDAY)
End If
If gdtToday <CDate(Format(Now, "M/d/yyyy")) Then
HandleDateChange() ' Do Midnight code now
If glWhichFace <iNewFace Then
Select Case iNewFace
Case Faces.HAPPY_FACE
Me.Icon = My.Resources.Happy_Face
Case Faces.MEDIUM_FACE
Me.Icon = My.Resources.Medium_Face
Case Faces.SAD_FACE
Me.Icon = My.Resources.Sad_Face
Case Faces.RED_FACE
Me.Icon = My.Resources.Red_Face
Case Faces.SLEEPY_FACE
Me.Icon = My.Resources.Sleeping_Face
End Select
NotifyIcon.Icon = Me.Icon
End If
'The Trend file gets reopened for one more write at midnight. Now
close it down, if opened and sleeping.
If iNewFace = Faces.SLEEPY_FACE AndAlso glWhichFace <iNewFace
AndAlso gbTrendFileOpenStatus = TREND_FILE_OPEN Then
FileClose(giTrendFileNo)
gbTrendFileOpenStatus = TREND_FILE_CLOSED
'If we are asleep and the FTP site is defined, it is after noon
and no FTP has been done then FTP the file to the backup site.
If Not gbTrendFile_Daily_FTP_Done AndAlso gsFTPSite <"" AndAlso
Hour(Now) 12 Then DoFTP_TrendFile()
End If
If glWhichFace <iNewFace Then
Dim NewFace As Faces = CType(iNewFace, Faces)
StatusAdd("Changed ICONs to " & NewFace.ToString)
glWhichFace = iNewFace
NewFace = Nothing
End If
'This is a stop gap in case the program was not running at midnight
but was started the next day.
'I guess this obviates the need for the midnight entry but I will
leave it in. I takes so little space and
'it is comfortable there.
If Format(gdtLastTrendDate, "short date") <Format(Now, "short
date") Then
gdtLastTrendDate = Now
glMidNightKWs = glLifetimeKW
End If
'Keep trying to FTP once per hour until it is done properly.
If glWhichFace = Faces.SLEEPY_FACE AndAlso Not
gbTrendFile_Daily_FTP_Done AndAlso Minute(Now) = 0 AndAlso Hour(Now) >
12 Then DoFTP_TrendFile()
lckCondx.EnterReadLock()
If Strings.UCase(gsWX_WindDir) = "CALM" Then
lblWindInfo.Text = gsWX_WindDir & vbCrLf & gsUpdtTime ' ° removed
Else
lblWindInfo.Text = gsWX_WindDir & " " & gsWX_WindSpeed & vbCrLf &
gsUpdtTime ' ° removed
End If
Application.UseWaitCursor = False
lblAmbient.Text = CStr(glAmbientTemp) & "° " & gsTempUnit & " / " &
gsWX_Condx
lckCondx.ExitReadLock()
CannotWrite:
StatusAdd("Cannot write to TrendFile, trying to open again.")
OpenTrendFile()
Resume
End Sub
Do you have option strict on and option option explicit on.
If not turn them on and you might see where the error is.
LS
<Ju********@home.netwrote in message
news:nm********************************@4ax.com...
>I tried to put an "on error" statement in a routine and got the message
that I cannot user "on error" and a lamda or query expression in the
same routine.
Help does not list anything useful for explaining a "lamda" expression
and so I don't know what one is and I am not doing any database stuff in
the entire program.
So what does this error message really mean and what can I do to get an
On Error into the routine?
NO, DON'T tell me to use Try/Catch because it is an incomplete
implementation that does not allow control to get back to the failing
line of code after attempting a fixup of the problem.
Well, you had better come up with something else, because it doesn't like
it.
Your friend is Google or Dogpile.com http://msdn.microsoft.com/en-us/library/bb763077.aspx http://msdn.microsoft.com/en-us/library/bb531253.aspx
Well, I never intentionally coded a lamda expression and still don't
think I have one. They seem awfully odd. And I don't like it, either.
Thanks for the useless reply. If I actually had one, I would get rid of
it!
Mike
On Sun, 13 Jul 2008 16:06:33 -0400, in
microsoft.public.dotnet.languages.vb "Mr. Arnold" <MR. Ar****@Arnold.comwrote:
>Well, you had better come up with something else, because it doesn't like it.
I can't run with Strict On and run due to another wonderful
inconsistency in VS. I will turn it on and see if anything else pops
up, then turn it back off so I can run. Last time I turned it on to
clean up anything, all was well.
Since, after reading what a lamda statement is, I still don't know what
one is, I doubt I have one and there are no LINQ or databases used in
the program, anywhere.
Too bad that VS's Help did not send me to anything even close to
explaining what a lamda expression is...
Mike
On Sat, 12 Jul 2008 19:04:45 -0400, in
microsoft.public.dotnet.languages.vb "Lloyd Sheen" <a@b.cwrote:
>Do you have option strict on and option option explicit on.
If not turn them on and you might see where the error is.
LS
Stict On just points out the obvious problem with a call to the thing I
would love to get rid of but can't until I find a way to send a UDP
message. I can find lots of HTTP examples but no UDP sample code.
I found the problem that this statement was going to help me with so,
for now, it is a non-issue. I had restructured the midnight process and
missed one file close switching from write to read and back to write.
The On Error was going to catch the problem and close the file, then try
the open again to fix it until I could find where the problem really
was. Found it, finally.
When working on too many things at once, sometimes a band-aid stops the
bleeding until you can fix the real problem. And then it claims I am
using lamda expressions.... sigh.....
I guess there is a need for lamda expressions but I surely can't think
of one right now and I don't have one in my code, best I can see. I
wish someone had put some thought elsewhere instead of writing that
obscure little bit of statement handling code. The closest I have is
initializing a value in a Dim statement. I don't know if that qualifies
but I will remove them and see if it changes the message and report back
if any update.
Thanks anyway,
Mike
On Sat, 12 Jul 2008 19:04:45 -0400, in
microsoft.public.dotnet.languages.vb "Lloyd Sheen" <a@b.cwrote:
>Do you have option strict on and option option explicit on.
If not turn them on and you might see where the error is.
LS
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dries |
last post by:
A friend of mine has a problem with his credit card validation routine
and it is probably a simple thing to solve but I cannot find it.
It has to do with the expiry dates.
What happens is that as...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: AAVF |
last post by:
Hi
We have a problem with a query.
An Access database links via ODBC to a UNIX server. To speed things, we use
the ODBC to load the relevant tables to the local PC that runs Access so
that...
|
by: John Øllgård Jensen |
last post by:
Hi
Using MS Asccess 2000:
In a query I'm trying to create a new field with following expression:
FilmDate: Left(,4)
The field "FilmNo" is another text field in the query.
This is...
|
by: nephish |
last post by:
Hey there,
i have been learning python for the past few months, but i can seem to
get what exactly a lamda is for. What would i use a lamda for that i
could not or would not use a def for ? Is...
|
by: Chuck |
last post by:
Please help me correct the statements in sub "BoundData"
The following sub is in a module. Everything runs with no error messages,
however,data is not reaching the text box. Data is being...
|
by: gnewsgroup |
last post by:
I want to get my hands dirty with Linq, so I watched a few videos from
www.asp.net, and then turned to
http://msdn2.microsoft.com/en-us/library/bb397687.aspx
for some introduction about the...
|
by: Stefano Sabatini |
last post by:
Hi all, I'm encountering this while trying to implement a factory
singleton method to generate objects.
The singleton has a static map which binds a static creation function
defined in each...
|
by: peter stickney |
last post by:
I am running CentOS 5.2, with all current updates
PHP 5.1.6 -
PHP 5.1.6 (cli) (built: Jul 16 2008 19:53:00)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |