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
#2
yeah i had that same problem. It's weird, but when i quit using "Erase Buffer", the error went away...
Reply
#3
Perfect, thanks
Reply
#4
Are you rewriting ver's tutorial and/or releasing a code with working byte arrays?
Reply
#5
Im shifting through the Kingdom of Cryshall code as well as the VBGore code Smile To answer your question, I'm using Socket Tools for my project, and figured i'd try out the byte based networking route for this bugger.

I'm create a few classed for use with Socket Tools and the networking. Once I am finished with the conversion, I'm looking at releasing the classes and tutorial on how to use the classes on this forum.
Reply
#6
I just store a separate variable that keeps track of the array UBound(), this way you don't have to call for the UBound() along with don't have to worry about the array not existing (UBound returning an error). When you erase the array, you just set your UBound variable to -1. I would presume erasing is faster then redimming 0 since theres no memory it has to try and preserve, along with you free up that last index.
Reply
#7
Shan you cant set buffer =" " has to be buffer = ""
Reply
#8
Dave Wrote:You don't need to do Buffer="" for some things. If I remember correctly, if the packet has a string in it you need to do it. Haven't messed with it for a while, and instead of testing each packet it's easier to just include that lien.

iw as jsut saying, since shan posted it as Buffer=" ", i believe its only used once.
Reply
#9
I was talking to Shan about that last night, he said he fixed that issue long ago. Lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)