CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2001
    Posts
    2

    reserving memory question

    Hi, if I define a structure in VB, what is the most common way to reserve memory for it. Thank you


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: reserving memory question


    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.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Oct 2001
    Posts
    2

    Re: reserving memory question

    when do you use api call like globalalloc then? Thanks!


  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: reserving memory question

    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.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080

    Re: reserving memory question

    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.

    Nicolas Bohemier

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured