When to use parenthesis and when not to use parenthesis while assigning variables in VB6?

vb6

Solution

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:

call StringToByteArray(UHeader.ProgramId(), "ABCDPQRS")

But this is also valid:

call StringToByteArray(UHeader.ProgramId, "ABCDPQRS")

It would probably make more sense to you if the StringToByteArray method was a function instead of a subroutine:

Private Function StringToByteArray(ByVal strValue As String) As Byte()
    'conversion code left out
End Function

Then you can call it like this:

UHeader.ProgramId() = StringToByteArray("ABCDPQRS")

or this:

UHeader.ProgramId = StringToByteArray("ABCDPQRS")

Problem

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?

Original source