Here's the code you wanted:
'---------------------------------------------------------------------------------------
' Module : PacketWriter
' Author : Joe[x86]
' Purpose : This will take input, convert it to a byte array, and return it when
' requested.
'---------------------------------------------------------------------------------------
Option Explicit
' The initial size of the buffer, in bytes
Private Const CONST_INITIALSIZE As Integer = 128
' Maximum size of the buffer, in bytes
Private Const CONST_MAXSIZE As Integer = 1024
' Ammount of bytes to grow the buffer by, when it must increase
Private Const CONST_GROWBY As Integer = 16
' Current length of the buffered data
Private CURRENTLENGTH As Integer
' Current size of the buffer
Private CURRENTSIZE As Integer
' Byte array which holds the data
Private DATA() As Byte
Private Sub Class_Initialize()
Call Reset
End Sub
Public Sub Reset()
ReDim DATA(1 To CONST_INITIALSIZE)
CURRENTSIZE = UBound(DATA)
CURRENTLENGTH = 0
End Sub
Private Sub Grow()
ReDim Preserve DATA(1 To UBound(DATA) + CONST_GROWBY)
CURRENTSIZE = UBound(DATA)
End Sub
'---------------------------------------------------------------------------------------
' This inserts a byte, but not before making sure we actually have room to do it.
'---------------------------------------------------------------------------------------
Public Sub addByte(B As Byte)
If CURRENTLENGTH + 1 >= CURRENT_SIZE Then
Call Grow
Call addByte(B)
End If
CURRENTLENGTH = CURRENTLENGTH + 1
DATA(CURRENTLENGTH) = B
End Sub
'---------------------------------------------------------------------------------------
' This inserts a Double Word. Did I get byte order right? :-\.
'---------------------------------------------------------------------------------------
Public Sub addDWord(D As Long)
If (Len(D) < 4) Then Exit Sub
Call addByte(D & &HFF)
Call addByte(D & &HFF00)
Call addByte(D & &HFF0000)
Call addByte(D & &HFF000000)
End Sub
'---------------------------------------------------------------------------------------
' This inserts a Null-Terminated (AKA, C-Style) string.
'---------------------------------------------------------------------------------------
Public Sub addCString(S As String)
Dim I As Integer ' Counter
For I = 1 To Len(S) Step 1
addByte (Asc(Mid(S, I, 1)))
Next I
Call addByte(0)
End Sub
'---------------------------------------------------------------------------------------
' This one's weird, because you have bytes mangling at the end if you don't ReDim it
' to the right length.
'---------------------------------------------------------------------------------------
Public Function getData() As Byte()
ReDim Preserve DATA(1 To CURRENTLENGTH)
getData = DATA
ReDim Preserve DATA(1 To CURRENTSIZE)
End Function
For what you were going to do, just call addByte(&H--) for each value.