Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
aLen use?
#1
Been looking through some sources, alen is being a pos, even though instructions followed .. bah ...

Code:
Public Function aLen(ByRef dBytes() As Byte) As Long
    On Error Resume Next
    
    aLen = (UBound(dBytes) - LBound(dBytes)) + 1
  
    If Err.Number  0 Then
      aLen = 0
      Err.Clear
    End If
End Function

Use would be ...

Code:
Dim Buffer() as byte

Erase Buffer
Buffer = ""
Buffer = AddByteToBuffer(Buffer, 1)

The above always result in a runtime error ... now according to the instructions :

Quote:'One thing to note, always initialize your byte array to "".
'i.e. dBytes = ""
'This sets the UBound of the byte array to -1, allowing us
'to have a size of 0. If the array is not initialized, or
'you have emptied the array, aLen will cause a RT error.

Doesn't seem to be accurate. As shown by the code above, I shouldn't receive a runtime error.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)