I am looking at some old VB6 code. I am new to VB and I come from a C/Java background, so I don’t understand some of the assignment statements. Here is one example –
Private Type UGH
Rsp(3) As Byte
ProgramId(7) As Byte
RID(7) As Byte
TID(3) As Byte
FL(39) As Byte
End Type
Private UHeader As UGH
Later, the assignment takes place as follows-
With UHeader
StringToByteArray UHeader.ProgramId(), "ABCDPQRS"
My question is, why is the parenthesis used after ProgramId in the above assignment? To me it seems like a function call, but it obviously is not a function call. Then what is it?
Well it is not actually needed. Calling the same line without the parenthesis will do exactly the same thing. The reason it is allowed is because it is a byte array.
Maybe rewriting the line like this will make it more readable:
But this is also valid:
It would probably make more sense to you if the StringToByteArray method was a function instead of a subroutine:
Then you can call it like this:
or this: