I posted earlier today about a MSComm question - reading byte data in... I couldn't get some of the code to compile when placed inside my subroutine, but I pasted the MSDN code example into it's own subroutine and it DOES compile. I'm just trying to understand how/why. (I will paste the code again below). I'm new to this but looking at the code below it looks like "Dim Arr() as Byte" declares an undimensioned Array. I thought that it would need a "ReDim" statement before use, but there is not one to be found..

"Buffer" (Variant) is assigned the MSComm1.Input (will return 10 bytes)

Assuming "Buffer" gets 10 bytes and then "Buffer" is assigned to "Arr" (which never got dimensioned), does "Arr()" now have a dimension - the size of the 10 bytes of data "Buffer" was holding????? Can you index "Arr" to read the bytes, and assume index 0 to 9? Is there a "Sizeof" operator to get the size of Arr in case "Buffer" had (in another operation) received some unknown # of bytes?

So can anyone explain this code and the way these variables work? Sorry, I'm just not hitting on the explanations I want in the MSDN Library.

Thanks for any help, Dale

Straight from the MSDN Library for VB6 proffessional, SP6
==============================
'InputMode Property Example
'This example reads 10 bytes of binary data from the communications port 'and assigns it to a byte array.

Private Sub Command1_Click()
Dim Buffer as Variant
Dim Arr() as Byte

' Set and open port
MSComm1.CommPort = 1
MSComm1.PortOpen = True

' Set InputMode to read binary data
MSComm1.InputMode = comInputModeBinary

' Wait until 10 bytes are in the input buffer
Do Until MSComm1.InBufferCount < 10
DoEvents
Loop

' Store binary data in buffer
Buffer = MSComm1.Input

' Assign to byte array for processing
Arr = Buffer

End Sub