I am new to VB. I am reading some VB6 code and I come across declaration statements like
PQR_SSN(8) As Byte // this probably refers to social security number
TR_DATA(7) As TransactionDetail
In another file, TransactionDetial is defined
Public Type TransactionDetail
A(0) As Byte
B(0) As Byte
Comment(40) As Byte
//... etc
//...
End Type
Does TR_DATA(7) mean that it is an “array” that can store 8 instances of TransactionDetail?
Also, Consider Comment(40). Can I access individual bytes of the comment like this –
Comment(3)
Also, suppose that I do not assign all 41 bytes to Comment. Then will the rest of the bytes contain garbage values?
Please help. Thanks.
Yes, TR_DATA(7) is an array of 8 elements of type TransactionDetail.
Yes, the Comments array can be accessed through individual elements as you show.
Unassigned elements may contain garbage values – I wouldn’t trust them – but I can’t recall whether VB helpfully pre-initialises variables. I would expect it would, just to be helpful to users, and that it would initialise numeric variables to 0, fixed-length strings to all zeros, and objects to Empty.
Found this web link which gives some useful guidance on arrays in VB6.
Also just found this: VB6 Variable Scope; which says: