|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help using <flags>equipment status. The results are returned in 6 groups - like 0A 40 08 00 00 00. Currently only the first 3 bytes contain meaningful info each bit reports either normal operation (a 0) or an error condition (a 1) for a component of the equipment. I set up <flag> Enum for each byte (just the first 3 for now) Enum Byte1 None=0 component1=1 component2 =2 component3 = 4 .... to 128 end enum Enum Byte2 None=0 component1=1 component2 =2 component3 = 4 .... to 128 end enum i need a routine that will quickly anaylyze and let me test the status of each flag. Thanks. O would build a routine similar to:
Private Sub sysCheckForErrors(ByVal strHexByte As String) Dim lngByte As Long Dim i As Integer 'Change hex to decimal. lngByte = Val("&H" & strHexByte) 'Do only if byte contains error. If lngByte <> 0 Then 'Scan each bit for ON position(1). For i = 0 To 7 If (lngByte And 2 ^ i) = 0 Then 'No error. MsgBox "Bit " & i & ": No error" Else 'Error on bit i. MsgBox "Bit " & i & ": Error!" End If Next i End If End Sub Call it passing the hex byte. Scan each bit looking for a 1. If a 1 is found, then an error condition exists. Take whatever action is necessary depending on which bit (value of i) it happened. HTH Saga Show quoteHide quote "Bob Harrison" <BobHarri***@discussions.microsoft.com> wrote in message news:EC87ADF5-6977-48FE-9612-AB112BDB6712@microsoft.com... >i am monitoring some electronic equipment. Every few seconds i poll for > equipment status. The results are returned in 6 groups - like 0A 40 08 > 00 00 > 00. Currently only the first 3 bytes contain meaningful info > > each bit reports either normal operation (a 0) or an error condition > (a 1) > for a component of the equipment. > > I set up <flag> Enum for each byte (just the first 3 for now) > Enum Byte1 > None=0 > component1=1 > component2 =2 > component3 = 4 > ... to 128 > end enum > > Enum Byte2 > None=0 > component1=1 > component2 =2 > component3 = 4 > ... to 128 > end enum > > i need a routine that will quickly anaylyze and let me test the status > of > each flag. > > Thanks. "Bob Harrison" <BobHarri***@discussions.microsoft.com> wrote in message On the basis of your statement above I'm going to assume you're not using news:EC87ADF5-6977-48FE-9612-AB112BDB6712@microsoft.com... > I set up <flag> Enum for each byte (just the first 3 for now) VB6, and therefore... This is a VB "classic" newsgroup. Questions about VB.NET (including VB 2005, which has dropped .NET from its name) are off-topic here. Please ask .NET questions in newsgroups with "dotnet" in their names. The *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.* groups on your news server, connect directly to the Microsoft server: msnews.microsoft.com. You can have enums in VB6:
Enum x2 de = 2 dc = 3 df = 4 End Enum Or is it just Friday and I missed something dot-nettish? Regards, Saga Show quoteHide quote "Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message news:%23UvpWLQKGHA.2304@TK2MSFTNGP15.phx.gbl... > > "Bob Harrison" <BobHarri***@discussions.microsoft.com> wrote in > message news:EC87ADF5-6977-48FE-9612-AB112BDB6712@microsoft.com... > >> I set up <flag> Enum for each byte (just the first 3 for now) > > On the basis of your statement above I'm going to assume you're not > using VB6, and therefore... > > This is a VB "classic" newsgroup. Questions about VB.NET (including VB > 2005, which has dropped .NET from its name) are off-topic here. > > Please ask .NET questions in newsgroups with "dotnet" in their names. > The > *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.* > groups on your news server, connect directly to the Microsoft server: > msnews.microsoft.com. > "Saga" <antiSpam@somewhere.com> wrote in message "<flags>" is a very .NET-ish looking attribute. You can mark an enum with news:OXFgTdQKGHA.140@TK2MSFTNGP12.phx.gbl... > You can have enums in VB6: > > Enum x2 > de = 2 > dc = 3 > df = 4 > End Enum > > Or is it just Friday and I missed something dot-nettish? this attribute and then when you view it in debug windows you'll not only see its numeric value but a comma-separated list indicating what flags are set. |
|||||||||||||||||||||||