Visual Basic 5 Curiosities

All examples were tested with VB5.

Arrays with zero Items

Private Sub Command1_Click()
    Dim buffer(3) As Byte
    Dim arr() As Byte
    arr = MidB(buffer, 1, 0)
    Call MsgBox(LBound(arr) & " / " & UBound(arr))
    ' LBound is 0 and UBound is -1
    ' but ReDim arr(0 to -1) is not allowed. Why?
End Sub
 

Assigning Arrays

Private Sub Form_Load()
    Dim byteBuf(3) As Byte
    Dim byteSeq() As Byte
    byteSeq = byteBuf        ' Is allowed
    Dim longBuf(3) As Long
    Dim longSeq() As Long
    longSeq = longBuf        ' Is not possible. Why?
End Sub
 

Long VB names

It is not possible to compile VB programs to executable files if project name plus class name has more than 39 characters due to a limitation of VB5 and ActiveX.

Garbage collection of weak circular references

VB do not garbage collection of weak circular references. A reason of some memory leaks in VB applications. ActiveX EXE doesn´t terminate if circular references exists.