Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Packet Enum - Completed
#22
I'd just like to add a little note about this tutorial, if I may.

Any variable declared of a custom Enum type will be 4 bytes.

I even made a quick test program to confirm this.

I had one form, and one module.
In the module, I had this code:
Code:
Public Enum PacketName
    First = 1
    Second
    Third
    Fourth
    Fifth
    Sixth
    Seventh
    Eighth
    Ninth
    Tenth
End Enum
In the form, I had this code:
Code:
Private Sub Form_Load()
    Dim myEnumVar As PacketName
    
    myEnumVar = Fifth
    
    MsgBox "myEnumVar: " & Str$(myEnumVar) & vbNewLine & "LenB: " & LenB(myEnumVar)
    End
End Sub

When I ran the program, I got a message box containing this:
MessageBox Wrote:myEnumVar: 5
LenB: 4

I felt I needed to bring that to light since it was mentioned in the tutorial that it would make the packet ID be 1-2 bytes, but it will indeed be a full four bytes.
Of course, the way to make them 1 or 2 bytes is to have a bunch of constants set as bytes or integers. But by nature, all Enums are of data type Long.

P.S. I believe I may still have a copy of Verrigan's "binary packet" MSE where he tweaked all of the stuff. Granted, I can't check until I can get back to my computer at home.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)