Click to See Complete Forum and Search --> : reserving memory question


cosjtm
October 17th, 2001, 05:01 AM
Hi, if I define a structure in VB, what is the most common way to reserve memory for it. Thank you

Clearcode
October 17th, 2001, 05:15 AM
Dim variablename as structuretype






-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.

cosjtm
October 17th, 2001, 10:13 PM
when do you use api call like globalalloc then? Thanks!

Clearcode
October 18th, 2001, 06:10 AM
You would only need to use GlobalAlloc if you want your data structure to be available to another application than the one it is declared in...and it is a pain to use from VB!

HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.

Boumxyz2
October 18th, 2001, 08:33 AM
Just declare it. There's a garbage collector in VB and you should be ok. Most VB arrays can be dynamically expanded and reduced and the same is true for strings. The good thing is that it is transparent and you don't need to do the mechanics to allocate new memory just like C++ or other language. Arrays are treated a bit differently and at least you get a fault if you try to access out of the range of it.