Does anybody know how I would |Bload something I previously bsaved into an array ?

Dani AI

Generated

A short expert note to follow up on this thread: as discovered, pointer-style access (VarPtr / VarSeg and similar tricks) only makes sense after the runtime has created the array's actual data buffer. Those helpers are undocumented and rely on a valid, allocated block of memory; calling them on an uninitialized dynamic array will not produce a usable address. 's suggestion to check a tips page was a sensible direction for background reading.

A safe, simple pattern in classic VB for loading raw bytes into an array is to size a Byte array to the file length and read with the Binary Get statement. Example:

Dim data() As Byte
Dim n As Long
n = FileLen("myfile.bin")
ReDim data(0 To n - 1)
Open "myfile.bin" For Binary As #1
Get #1, , data
Close #1

Troubleshooting and cautions: always verify the expected byte count and array bounds before reading. For user-defined types, raw memory layout and padding can differ, so field-by-field serialization is safer than blasting memory into a UDT. Because VarPtr/VarSeg are undocumented and not portable (and do not exist in .NET), consider supported APIs instead — ADODB.Stream in VB6 or System.IO.File.ReadAllBytes in VB.NET — when portability and future maintenance matter.

Recommended Answers

All 2 Replies

You might try my tips page to see if there is any help there

then go to the tips page.

Thanks, I figured it out, you have create put something into the array first before you can access it using varseg or varptr

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.