I have a bunch of 50 bytes I would like to write to a file in VBA.
One way of doing this is to enter them in separate cells on a worksheet (say A1 to A50), and write a loop in VBA to write each one to the file.
However, I would rather not have the data on a worksheet in the first place. My plan is to put these 50 bytes into an array using VBA directly, and then write a loop to write each byte to the file.
Something like:
The red line is the one which I can't fix. Is there a way of populating an array quickly i.e. in one or two lines? (I could of course populate the array from the worksheet, but then there's no point using an array any more... )
I used to have a ZX Spectrum (those were the days!!!), and there I would type in:
Data 1, 4, 29, 35, ...
and use the Read statement to pick out the numbers one by one.
Any ideas, apart from using a string instead, and messing about with delimeters?
Thanks,
Bluto
One way of doing this is to enter them in separate cells on a worksheet (say A1 to A50), and write a loop in VBA to write each one to the file.
However, I would rather not have the data on a worksheet in the first place. My plan is to put these 50 bytes into an array using VBA directly, and then write a loop to write each byte to the file.
Something like:
Code:
Dim myarray(50) As Byte
Dim n As Integer
[COLOR=red]myarray = (1, 4 ,29, 35, 246, [I]...more bytes in here...[/I], 8)[/COLOR]
Open "file" For Binary As #1
For n = 1 to 50
Put #1 , , myarray(n)
Next n
The red line is the one which I can't fix. Is there a way of populating an array quickly i.e. in one or two lines? (I could of course populate the array from the worksheet, but then there's no point using an array any more... )
I used to have a ZX Spectrum (those were the days!!!), and there I would type in:
Data 1, 4, 29, 35, ...
and use the Read statement to pick out the numbers one by one.
Any ideas, apart from using a string instead, and messing about with delimeters?
Thanks,
Bluto